From 329927f976991be283cedf928249abf55b8d8d04 Mon Sep 17 00:00:00 2001 From: andrey1s Date: Mon, 26 Apr 2021 16:21:12 +0300 Subject: [PATCH] update lint --- .golangci.yml | 9 +++++++++ gob/encoding.go | 6 ++++-- gob/unmarshal.go | 6 ++++-- json/encoding.go | 6 ++++-- test/decode_suite.go | 4 ++++ toml/encoding.go | 7 +++++-- toml/encoding_test.go | 1 + xml/encoding.go | 6 ++++-- yaml/encoding.go | 6 ++++-- yaml/encoding_test.go | 1 + 10 files changed, 40 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 672df6e..8935283 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,6 +22,11 @@ linters-settings: linters: enable-all: true + disable: + - scopelint + - maligned + - interfacer + - wrapcheck issues: # Excluding configuration per-path, per-linter, per-text and per-source @@ -29,3 +34,7 @@ issues: - path: _test\.go linters: - gomnd + - path: _suite\.go + linters: + - exhaustivestruct + - gomnd diff --git a/gob/encoding.go b/gob/encoding.go index 715b60c..ff6969d 100644 --- a/gob/encoding.go +++ b/gob/encoding.go @@ -7,8 +7,10 @@ import ( "gitoa.ru/go-4devs/encoding" ) -var _ encoding.Decode = Decode -var _ encoding.Encode = Encode +var ( + _ encoding.Decode = Decode + _ encoding.Encode = Encode +) func Decode(r io.Reader, v interface{}) error { return gob.NewDecoder(r).Decode(v) diff --git a/gob/unmarshal.go b/gob/unmarshal.go index b622c62..90946a0 100644 --- a/gob/unmarshal.go +++ b/gob/unmarshal.go @@ -7,8 +7,10 @@ import ( "gitoa.ru/go-4devs/encoding" ) -var _ encoding.Unmarshal = Unmarshal -var _ encoding.Marshal = Marshal +var ( + _ encoding.Unmarshal = Unmarshal + _ encoding.Marshal = Marshal +) // Unmarshal by gob decoder. func Unmarshal(data []byte, v interface{}) error { diff --git a/json/encoding.go b/json/encoding.go index ceb9c35..722be61 100644 --- a/json/encoding.go +++ b/json/encoding.go @@ -7,8 +7,10 @@ import ( "gitoa.ru/go-4devs/encoding" ) -var _ encoding.Decode = Decode -var _ encoding.Encode = Encode +var ( + _ encoding.Decode = Decode + _ encoding.Encode = Encode +) func Decode(r io.Reader, v interface{}) error { return json.NewDecoder(r).Decode(v) diff --git a/test/decode_suite.go b/test/decode_suite.go index 7ae1ed8..7bfc01e 100644 --- a/test/decode_suite.go +++ b/test/decode_suite.go @@ -16,6 +16,7 @@ type Data struct { Time time.Time Struct SData } + type SData struct { ID int64 } @@ -36,6 +37,8 @@ type DecodeSuite struct { // RunSute run test by provider. func RunDecode(t *testing.T, decode encoding.Decode, data string) { + t.Helper() + cs := DecodeSuite{ decode: decode, data: bytes.NewBufferString(data), @@ -43,6 +46,7 @@ func RunDecode(t *testing.T, decode encoding.Decode, data string) { suite.Run(t, &cs) } + func (ds *DecodeSuite) TestDecode() { var d Data diff --git a/toml/encoding.go b/toml/encoding.go index 331e096..2259c0d 100644 --- a/toml/encoding.go +++ b/toml/encoding.go @@ -7,12 +7,15 @@ import ( "gitoa.ru/go-4devs/encoding" ) -var _ encoding.Decode = Decode -var _ encoding.Encode = Encode +var ( + _ encoding.Decode = Decode + _ encoding.Encode = Encode +) // Decode from reader to value. func Decode(r io.Reader, v interface{}) error { _, err := toml.DecodeReader(r, v) + return err } diff --git a/toml/encoding_test.go b/toml/encoding_test.go index c7f4f81..f3228d6 100644 --- a/toml/encoding_test.go +++ b/toml/encoding_test.go @@ -15,5 +15,6 @@ id = 42 ` func TestDecode(t *testing.T) { + t.Parallel() test.RunDecode(t, toml.Decode, data) } diff --git a/xml/encoding.go b/xml/encoding.go index a223127..bbdff5e 100644 --- a/xml/encoding.go +++ b/xml/encoding.go @@ -7,8 +7,10 @@ import ( "gitoa.ru/go-4devs/encoding" ) -var _ encoding.Decode = Decode -var _ encoding.Encode = Encode +var ( + _ encoding.Decode = Decode + _ encoding.Encode = Encode +) // Decode from xml. func Decode(r io.Reader, v interface{}) error { diff --git a/yaml/encoding.go b/yaml/encoding.go index 1f71bfb..d184f75 100644 --- a/yaml/encoding.go +++ b/yaml/encoding.go @@ -7,8 +7,10 @@ import ( "gopkg.in/yaml.v3" ) -var _ encoding.Decode = Decode -var _ encoding.Encode = Encode +var ( + _ encoding.Decode = Decode + _ encoding.Encode = Encode +) // Decode from reader to value. func Decode(r io.Reader, v interface{}) error { diff --git a/yaml/encoding_test.go b/yaml/encoding_test.go index a5e32bd..4bf208b 100644 --- a/yaml/encoding_test.go +++ b/yaml/encoding_test.go @@ -15,5 +15,6 @@ struct: ` func TestDecode(t *testing.T) { + t.Parallel() test.RunDecode(t, yaml.Decode, data) }