Skip to content

Commit 8d867ff

Browse files
committed
fix: Prioritize TextMarshaler for argument serialization (#3139)
* Ensures types implementing both TextMarshaler and BinaryMarshaler are marshaled as text. * Also required reordering net.IP case to prevent string conversion due to added case.
1 parent 3498462 commit 8d867ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/proto/writer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ func (w *Writer) WriteArg(v interface{}) error {
185185
return w.int(0)
186186
}
187187
return w.int(v.Nanoseconds())
188+
case net.IP:
189+
return w.bytes(v)
188190
case encoding.TextMarshaler:
189191
b, err := v.MarshalText()
190192
if err != nil {
@@ -197,8 +199,6 @@ func (w *Writer) WriteArg(v interface{}) error {
197199
return err
198200
}
199201
return w.bytes(b)
200-
case net.IP:
201-
return w.bytes(v)
202202
default:
203203
return fmt.Errorf(
204204
"redis: can't marshal %T (implement encoding.BinaryMarshaler)", v)

0 commit comments

Comments
 (0)