Skip to content

Commit 6deeb9b

Browse files
committed
error: rename gojay method reciever name and compile time check pragma
1 parent bee6320 commit 6deeb9b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

error_gojay.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,30 @@ package jsonrpc2
99
import "github.com/francoispqt/gojay"
1010

1111
// UnmarshalJSONObject implements gojay's UnmarshalerJSONObject
12-
func (v *Error) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
12+
func (e *Error) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
1313
switch k {
1414
case keyCode:
15-
return dec.Int64((*int64)(&v.Code))
15+
return dec.Int64((*int64)(&e.Code))
1616
case keyMessage:
17-
return dec.String(&v.Message)
17+
return dec.String(&e.Message)
1818
}
1919
return nil
2020
}
2121

2222
// NKeys returns the number of keys to unmarshal
23-
func (v *Error) NKeys() int { return 2 }
23+
func (e *Error) NKeys() int { return 2 }
2424

2525
// MarshalJSONObject implements gojay's MarshalerJSONObject
26-
func (v *Error) MarshalJSONObject(enc *gojay.Encoder) {
27-
enc.IntKey(keyCode, int(v.Code))
28-
enc.StringKey(keyMessage, v.Message)
26+
func (e *Error) MarshalJSONObject(enc *gojay.Encoder) {
27+
enc.IntKey(keyCode, int(e.Code))
28+
enc.StringKey(keyMessage, e.Message)
2929
}
3030

3131
// IsNil returns wether the structure is nil value or not
32-
func (v *Error) IsNil() bool { return v == nil }
32+
func (e *Error) IsNil() bool { return e == nil }
33+
34+
// compile time check whether the Error implements a gojay.MarshalerJSONObject interface.
35+
var _ gojay.MarshalerJSONObject = (*Error)(nil)
36+
37+
// compile time check whether the Error implements a gojay.UnmarshalerJSONObject interface.
38+
var _ gojay.UnmarshalerJSONObject = (*Error)(nil)

0 commit comments

Comments
 (0)