Browse Source

update lint

pull/1/head v0.0.5
andrey1s 4 years ago
parent
commit
329927f976
  1. 9
      .golangci.yml
  2. 6
      gob/encoding.go
  3. 6
      gob/unmarshal.go
  4. 6
      json/encoding.go
  5. 4
      test/decode_suite.go
  6. 7
      toml/encoding.go
  7. 1
      toml/encoding_test.go
  8. 6
      xml/encoding.go
  9. 6
      yaml/encoding.go
  10. 1
      yaml/encoding_test.go

9
.golangci.yml

@ -22,6 +22,11 @@ linters-settings:
linters: linters:
enable-all: true enable-all: true
disable:
- scopelint
- maligned
- interfacer
- wrapcheck
issues: issues:
# Excluding configuration per-path, per-linter, per-text and per-source # Excluding configuration per-path, per-linter, per-text and per-source
@ -29,3 +34,7 @@ issues:
- path: _test\.go - path: _test\.go
linters: linters:
- gomnd - gomnd
- path: _suite\.go
linters:
- exhaustivestruct
- gomnd

6
gob/encoding.go

@ -7,8 +7,10 @@ import (
"gitoa.ru/go-4devs/encoding" "gitoa.ru/go-4devs/encoding"
) )
var _ encoding.Decode = Decode var (
var _ encoding.Encode = Encode _ encoding.Decode = Decode
_ encoding.Encode = Encode
)
func Decode(r io.Reader, v interface{}) error { func Decode(r io.Reader, v interface{}) error {
return gob.NewDecoder(r).Decode(v) return gob.NewDecoder(r).Decode(v)

6
gob/unmarshal.go

@ -7,8 +7,10 @@ import (
"gitoa.ru/go-4devs/encoding" "gitoa.ru/go-4devs/encoding"
) )
var _ encoding.Unmarshal = Unmarshal var (
var _ encoding.Marshal = Marshal _ encoding.Unmarshal = Unmarshal
_ encoding.Marshal = Marshal
)
// Unmarshal by gob decoder. // Unmarshal by gob decoder.
func Unmarshal(data []byte, v interface{}) error { func Unmarshal(data []byte, v interface{}) error {

6
json/encoding.go

@ -7,8 +7,10 @@ import (
"gitoa.ru/go-4devs/encoding" "gitoa.ru/go-4devs/encoding"
) )
var _ encoding.Decode = Decode var (
var _ encoding.Encode = Encode _ encoding.Decode = Decode
_ encoding.Encode = Encode
)
func Decode(r io.Reader, v interface{}) error { func Decode(r io.Reader, v interface{}) error {
return json.NewDecoder(r).Decode(v) return json.NewDecoder(r).Decode(v)

4
test/decode_suite.go

@ -16,6 +16,7 @@ type Data struct {
Time time.Time Time time.Time
Struct SData Struct SData
} }
type SData struct { type SData struct {
ID int64 ID int64
} }
@ -36,6 +37,8 @@ type DecodeSuite struct {
// RunSute run test by provider. // RunSute run test by provider.
func RunDecode(t *testing.T, decode encoding.Decode, data string) { func RunDecode(t *testing.T, decode encoding.Decode, data string) {
t.Helper()
cs := DecodeSuite{ cs := DecodeSuite{
decode: decode, decode: decode,
data: bytes.NewBufferString(data), data: bytes.NewBufferString(data),
@ -43,6 +46,7 @@ func RunDecode(t *testing.T, decode encoding.Decode, data string) {
suite.Run(t, &cs) suite.Run(t, &cs)
} }
func (ds *DecodeSuite) TestDecode() { func (ds *DecodeSuite) TestDecode() {
var d Data var d Data

7
toml/encoding.go

@ -7,12 +7,15 @@ import (
"gitoa.ru/go-4devs/encoding" "gitoa.ru/go-4devs/encoding"
) )
var _ encoding.Decode = Decode var (
var _ encoding.Encode = Encode _ encoding.Decode = Decode
_ encoding.Encode = Encode
)
// Decode from reader to value. // Decode from reader to value.
func Decode(r io.Reader, v interface{}) error { func Decode(r io.Reader, v interface{}) error {
_, err := toml.DecodeReader(r, v) _, err := toml.DecodeReader(r, v)
return err return err
} }

1
toml/encoding_test.go

@ -15,5 +15,6 @@ id = 42
` `
func TestDecode(t *testing.T) { func TestDecode(t *testing.T) {
t.Parallel()
test.RunDecode(t, toml.Decode, data) test.RunDecode(t, toml.Decode, data)
} }

6
xml/encoding.go

@ -7,8 +7,10 @@ import (
"gitoa.ru/go-4devs/encoding" "gitoa.ru/go-4devs/encoding"
) )
var _ encoding.Decode = Decode var (
var _ encoding.Encode = Encode _ encoding.Decode = Decode
_ encoding.Encode = Encode
)
// Decode from xml. // Decode from xml.
func Decode(r io.Reader, v interface{}) error { func Decode(r io.Reader, v interface{}) error {

6
yaml/encoding.go

@ -7,8 +7,10 @@ import (
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
var _ encoding.Decode = Decode var (
var _ encoding.Encode = Encode _ encoding.Decode = Decode
_ encoding.Encode = Encode
)
// Decode from reader to value. // Decode from reader to value.
func Decode(r io.Reader, v interface{}) error { func Decode(r io.Reader, v interface{}) error {

1
yaml/encoding_test.go

@ -15,5 +15,6 @@ struct:
` `
func TestDecode(t *testing.T) { func TestDecode(t *testing.T) {
t.Parallel()
test.RunDecode(t, yaml.Decode, data) test.RunDecode(t, yaml.Decode, data)
} }

Loading…
Cancel
Save