go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

fix: let Set to support custom type

Open oldme-git opened this issue 1 year ago • 1 comments

Dear review: Thanks for your reviewing

Set and other Set function can't use custom type. e.g.

func TestI(t *testing.T) {
  type myInt int
  var i myInt = 123

  err := rdb.Set(ctx, "key", i, 0).Err()
  if err != nil {
    t.Fatal(err)
  }
}

result: redis: can't marshal * (implement encoding.BinaryMarshaler)

It should add rereflect assertion after type assertion. I did it for performance and other types of considerations. for examole: time.Time or encoding.BinaryMarshaler

Have a good day!

fixed: #3104

oldme-git avatar Sep 04 '24 06:09 oldme-git

Hello @oldme-git, Would you mind adding a test case per type added in the reflect select ?

ndyakov avatar Feb 06 '25 21:02 ndyakov