redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
20.21k stars 2.38k forks source link

fix: let Set to support custom type #3105

Open oldme-git opened 2 months ago

oldme-git commented 2 months ago

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