Skip to content

rewrite interface{} to any #3386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ For example:
"idx:bicycle",
"@pickup_zone:[CONTAINS $bike]",
&redis.FTSearchOptions{
Params: map[string]interface{}{
Params: map[string]any{
"bike": "POINT(-0.1278 51.5074)",
},
DialectVersion: 3,
Expand Down
10 changes: 5 additions & 5 deletions acl_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package redis
import "context"

type ACLCmdable interface {
ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd
ACLDryRun(ctx context.Context, username string, command ...any) *StringCmd

ACLLog(ctx context.Context, count int64) *ACLLogCmd
ACLLogReset(ctx context.Context) *StatusCmd
Expand All @@ -20,8 +20,8 @@ type ACLCatArgs struct {
Category string
}

func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd {
args := make([]interface{}, 0, 3+len(command))
func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...any) *StringCmd {
args := make([]any, 0, 3+len(command))
args = append(args, "acl", "dryrun", username)
args = append(args, command...)
cmd := NewStringCmd(ctx, args...)
Expand All @@ -30,7 +30,7 @@ func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...inte
}

func (c cmdable) ACLLog(ctx context.Context, count int64) *ACLLogCmd {
args := make([]interface{}, 0, 3)
args := make([]any, 0, 3)
args = append(args, "acl", "log")
if count > 0 {
args = append(args, count)
Expand All @@ -53,7 +53,7 @@ func (c cmdable) ACLDelUser(ctx context.Context, username string) *IntCmd {
}

func (c cmdable) ACLSetUser(ctx context.Context, username string, rules ...string) *StatusCmd {
args := make([]interface{}, 3+len(rules))
args := make([]any, 3+len(rules))
args[0] = "acl"
args[1] = "setuser"
args[2] = username
Expand Down
2 changes: 1 addition & 1 deletion acl_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ var _ = Describe("ACL Categories", func() {
"tdigest": "tdigest.rank",
"timeseries": "ts.range",
}
var cats []interface{}
var cats []any

for cat, subitem := range aclTestCase {
cats = append(cats, cat)
Expand Down
2 changes: 1 addition & 1 deletion bench_decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func respString(b *testing.B, stub ClientStubFunc) {

func respArray(b *testing.B, stub ClientStubFunc) {
rdb := stub([]byte("*3\r\n$5\r\nhello\r\n:10\r\n+OK\r\n"))
var val []interface{}
var val []any

b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand Down
18 changes: 9 additions & 9 deletions bitmap_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type BitMapCmdable interface {
BitOpNot(ctx context.Context, destKey string, key string) *IntCmd
BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd
BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd
BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd
BitFieldRO(ctx context.Context, key string, values ...interface{}) *IntSliceCmd
BitField(ctx context.Context, key string, values ...any) *IntSliceCmd
BitFieldRO(ctx context.Context, key string, values ...any) *IntSliceCmd
}

func (c cmdable) GetBit(ctx context.Context, key string, offset int64) *IntCmd {
Expand Down Expand Up @@ -66,7 +66,7 @@ func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *
}

func (c cmdable) bitOp(ctx context.Context, op, destKey string, keys ...string) *IntCmd {
args := make([]interface{}, 3+len(keys))
args := make([]any, 3+len(keys))
args[0] = "bitop"
args[1] = op
args[2] = destKey
Expand Down Expand Up @@ -97,7 +97,7 @@ func (c cmdable) BitOpNot(ctx context.Context, destKey string, key string) *IntC
// BitPos is an API before Redis version 7.0, cmd: bitpos key bit start end
// if you need the `byte | bit` parameter, please use `BitPosSpan`.
func (c cmdable) BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd {
args := make([]interface{}, 3+len(pos))
args := make([]any, 3+len(pos))
args[0] = "bitpos"
args[1] = key
args[2] = bit
Expand Down Expand Up @@ -131,9 +131,9 @@ func (c cmdable) BitPosSpan(ctx context.Context, key string, bit int8, start, en
// BitField accepts multiple values:
// - BitField("set", "i1", "offset1", "value1","cmd2", "type2", "offset2", "value2")
// - BitField([]string{"cmd1", "type1", "offset1", "value1","cmd2", "type2", "offset2", "value2"})
// - BitField([]interface{}{"cmd1", "type1", "offset1", "value1","cmd2", "type2", "offset2", "value2"})
func (c cmdable) BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(values))
// - BitField([]any{"cmd1", "type1", "offset1", "value1","cmd2", "type2", "offset2", "value2"})
func (c cmdable) BitField(ctx context.Context, key string, values ...any) *IntSliceCmd {
args := make([]any, 2, 2+len(values))
args[0] = "bitfield"
args[1] = key
args = appendArgs(args, values)
Expand All @@ -145,8 +145,8 @@ func (c cmdable) BitField(ctx context.Context, key string, values ...interface{}
// BitFieldRO - Read-only variant of the BITFIELD command.
// It is like the original BITFIELD but only accepts GET subcommand and can safely be used in read-only replicas.
// - BitFieldRO(ctx, key, "<Encoding0>", "<Offset0>", "<Encoding1>","<Offset1>")
func (c cmdable) BitFieldRO(ctx context.Context, key string, values ...interface{}) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(values))
func (c cmdable) BitFieldRO(ctx context.Context, key string, values ...any) *IntSliceCmd {
args := make([]any, 2, 2+len(values))
args[0] = "BITFIELD_RO"
args[1] = key
if len(values)%2 != 0 {
Expand Down
4 changes: 2 additions & 2 deletions cluster_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c cmdable) ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd {
}

func (c cmdable) ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd {
args := make([]interface{}, 2+len(slots))
args := make([]any, 2+len(slots))
args[0] = "cluster"
args[1] = "delslots"
for i, slot := range slots {
Expand Down Expand Up @@ -166,7 +166,7 @@ func (c cmdable) ClusterFailover(ctx context.Context) *StatusCmd {
}

func (c cmdable) ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd {
args := make([]interface{}, 2+len(slots))
args := make([]any, 2+len(slots))
args[0] = "cluster"
args[1] = "addslots"
for i, num := range slots {
Expand Down
Loading
Loading