From d0f3c7e4d03162dc25e7b4cee7f4ff8ddb950d1e Mon Sep 17 00:00:00 2001 From: andrey1s Date: Tue, 6 Sep 2022 22:20:42 +0300 Subject: [PATCH] update golint --- .golangci.yml | 13 ++++++++++++- bench_test.go | 6 +++--- entry/pool.go | 4 ++-- field/encoder.go | 1 + field/field.go | 4 ++-- field/key.go | 2 +- field/value.go | 4 ++-- logger.go | 2 +- writter.go | 2 +- 9 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index dc58bb9..47cef9c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,6 +37,17 @@ linters-settings: linters: enable-all: true + disable: + - exhaustivestruct + - maligned + - deadcode + - interfacer + - golint + - varcheck + - nosnakecase + - scopelint + - ifshort + - structcheck issues: # Excluding configuration per-path, per-linter, per-text and per-source @@ -44,5 +55,5 @@ issues: - path: _test\.go linters: - gomnd - - exhaustivestruct - ireturn + - exhaustruct diff --git a/bench_test.go b/bench_test.go index 0a7bdac..9d003f0 100644 --- a/bench_test.go +++ b/bench_test.go @@ -4,7 +4,7 @@ import ( "context" "errors" "fmt" - "io/ioutil" + "io" "testing" "time" @@ -12,7 +12,7 @@ import ( "gitoa.ru/go-4devs/log/field" ) -// nolint: gochecknoglobals +//nolint:gochecknoglobals var ( errExample = errors.New("fail") _messages = fakeMessages(1000) @@ -118,7 +118,7 @@ func fakeSugarFields() []interface{} { } func NewLogger() log.Logger { - return log.New(log.WithWriter(ioutil.Discard)) + return log.New(log.WithWriter(io.Discard)) } func BenchmarkDisabledWithoutFields(b *testing.B) { diff --git a/entry/pool.go b/entry/pool.go index 5229eac..e98abc4 100644 --- a/entry/pool.go +++ b/entry/pool.go @@ -2,14 +2,14 @@ package entry import "sync" -// nolint: gochecknoglobals +//nolint:gochecknoglobals var pool = sync.Pool{ New: func() interface{} { return New() }, } -//nolint: forcetypeassert +//nolint:forcetypeassert func Get() *Entry { e := pool.Get().(*Entry) e.Reset() diff --git a/field/encoder.go b/field/encoder.go index bf16399..905eb2e 100644 --- a/field/encoder.go +++ b/field/encoder.go @@ -2,6 +2,7 @@ package field import "time" +//nolint:interfacebloat type Encoder interface { // Built-in types. AddArray(key string, value Value) diff --git a/field/field.go b/field/field.go index ab9bdfb..a3029d3 100644 --- a/field/field.go +++ b/field/field.go @@ -255,13 +255,13 @@ type Field struct { value Value } -//nolint: gocyclo,cyclop +//nolint:gocyclo,cyclop func (f Field) AddTo(enc Encoder) { key := string(f.key) switch { case f.value.IsArray(): - enc.AddAny(key, f.value) + enc.AddArray(key, f.value) case f.value.IsNil(): enc.AddNil(key) case f.value.IsBool(): diff --git a/field/key.go b/field/key.go index 6ddb843..febd38d 100644 --- a/field/key.go +++ b/field/key.go @@ -6,7 +6,7 @@ import ( type Key string -//nolint: gocyclo,funlen,cyclop +//nolint:funlen,cyclop,gocyclo func (k Key) Any(value interface{}) Field { switch val := value.(type) { case string: diff --git a/field/value.go b/field/value.go index d5846bb..c8b4283 100644 --- a/field/value.go +++ b/field/value.go @@ -24,7 +24,7 @@ func (v Value) MarshalJSON() ([]byte, error) { return b, nil } -//nolint: gocyclo,gomnd,cyclop +//nolint:gocyclo,gomnd,cyclop func (v Value) String() string { switch { case v.vtype.IsArray(), v.vtype.IsAny(): @@ -62,7 +62,7 @@ func (v Value) String() string { return fmt.Sprintf("%+v", v.AsInterface()) } -//nolint: gocyclo,cyclop +//nolint:gocyclo,cyclop func (v Value) AsInterface() interface{} { switch { case v.vtype.IsArray(): diff --git a/logger.go b/logger.go index 64ea93c..a1e1d8f 100644 --- a/logger.go +++ b/logger.go @@ -306,7 +306,7 @@ func (l Logger) Writer(ctx context.Context, level level.Level, fields ...field.F } } -//nolint: containedctx +//nolint:containedctx type writer struct { ctx context.Context level level.Level diff --git a/writter.go b/writter.go index 2387c7c..ce4eeca 100644 --- a/writter.go +++ b/writter.go @@ -76,7 +76,7 @@ func WithJSONFormat() Option { return WithEncode(jsonFormat) } -//nolint: forcetypeassert +//nolint:forcetypeassert func stringFormat() func(entry *entry.Entry) ([]byte, error) { pool := sync.Pool{ New: func() interface{} {