From af68caeaf68a12b8498a88eb6d4a00296a017c49 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 20 Feb 2021 16:59:31 +0800 Subject: [PATCH] fix golint issues in core/jsonx (#491) --- core/jsonx/json.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/jsonx/json.go b/core/jsonx/json.go index a1f5f7ef..c4f60b68 100644 --- a/core/jsonx/json.go +++ b/core/jsonx/json.go @@ -8,10 +8,12 @@ import ( "strings" ) +// Marshal marshals v into json bytes. func Marshal(v interface{}) ([]byte, error) { return json.Marshal(v) } +// Unmarshal unmarshals data bytes into v. func Unmarshal(data []byte, v interface{}) error { decoder := json.NewDecoder(bytes.NewReader(data)) if err := unmarshalUseNumber(decoder, v); err != nil { @@ -21,6 +23,7 @@ func Unmarshal(data []byte, v interface{}) error { return nil } +// UnmarshalFromString unmarshals v from str. func UnmarshalFromString(str string, v interface{}) error { decoder := json.NewDecoder(strings.NewReader(str)) if err := unmarshalUseNumber(decoder, v); err != nil { @@ -30,6 +33,7 @@ func UnmarshalFromString(str string, v interface{}) error { return nil } +// UnmarshalFromReader unmarshals v from reader. func UnmarshalFromReader(reader io.Reader, v interface{}) error { var buf strings.Builder teeReader := io.TeeReader(reader, &buf)