Browse Source

update golint

pull/6/head
andrey1s 2 years ago
parent
commit
d0f3c7e4d0
  1. 13
      .golangci.yml
  2. 6
      bench_test.go
  3. 4
      entry/pool.go
  4. 1
      field/encoder.go
  5. 4
      field/field.go
  6. 2
      field/key.go
  7. 4
      field/value.go
  8. 2
      logger.go
  9. 2
      writter.go

13
.golangci.yml

@ -37,6 +37,17 @@ linters-settings:
linters: linters:
enable-all: true enable-all: true
disable:
- exhaustivestruct
- maligned
- deadcode
- interfacer
- golint
- varcheck
- nosnakecase
- scopelint
- ifshort
- structcheck
issues: issues:
# Excluding configuration per-path, per-linter, per-text and per-source # Excluding configuration per-path, per-linter, per-text and per-source
@ -44,5 +55,5 @@ issues:
- path: _test\.go - path: _test\.go
linters: linters:
- gomnd - gomnd
- exhaustivestruct
- ireturn - ireturn
- exhaustruct

6
bench_test.go

@ -4,7 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"testing" "testing"
"time" "time"
@ -12,7 +12,7 @@ import (
"gitoa.ru/go-4devs/log/field" "gitoa.ru/go-4devs/log/field"
) )
// nolint: gochecknoglobals //nolint:gochecknoglobals
var ( var (
errExample = errors.New("fail") errExample = errors.New("fail")
_messages = fakeMessages(1000) _messages = fakeMessages(1000)
@ -118,7 +118,7 @@ func fakeSugarFields() []interface{} {
} }
func NewLogger() log.Logger { func NewLogger() log.Logger {
return log.New(log.WithWriter(ioutil.Discard)) return log.New(log.WithWriter(io.Discard))
} }
func BenchmarkDisabledWithoutFields(b *testing.B) { func BenchmarkDisabledWithoutFields(b *testing.B) {

4
entry/pool.go

@ -2,14 +2,14 @@ package entry
import "sync" import "sync"
// nolint: gochecknoglobals //nolint:gochecknoglobals
var pool = sync.Pool{ var pool = sync.Pool{
New: func() interface{} { New: func() interface{} {
return New() return New()
}, },
} }
//nolint: forcetypeassert //nolint:forcetypeassert
func Get() *Entry { func Get() *Entry {
e := pool.Get().(*Entry) e := pool.Get().(*Entry)
e.Reset() e.Reset()

1
field/encoder.go

@ -2,6 +2,7 @@ package field
import "time" import "time"
//nolint:interfacebloat
type Encoder interface { type Encoder interface {
// Built-in types. // Built-in types.
AddArray(key string, value Value) AddArray(key string, value Value)

4
field/field.go

@ -255,13 +255,13 @@ type Field struct {
value Value value Value
} }
//nolint: gocyclo,cyclop //nolint:gocyclo,cyclop
func (f Field) AddTo(enc Encoder) { func (f Field) AddTo(enc Encoder) {
key := string(f.key) key := string(f.key)
switch { switch {
case f.value.IsArray(): case f.value.IsArray():
enc.AddAny(key, f.value) enc.AddArray(key, f.value)
case f.value.IsNil(): case f.value.IsNil():
enc.AddNil(key) enc.AddNil(key)
case f.value.IsBool(): case f.value.IsBool():

2
field/key.go

@ -6,7 +6,7 @@ import (
type Key string type Key string
//nolint: gocyclo,funlen,cyclop //nolint:funlen,cyclop,gocyclo
func (k Key) Any(value interface{}) Field { func (k Key) Any(value interface{}) Field {
switch val := value.(type) { switch val := value.(type) {
case string: case string:

4
field/value.go

@ -24,7 +24,7 @@ func (v Value) MarshalJSON() ([]byte, error) {
return b, nil return b, nil
} }
//nolint: gocyclo,gomnd,cyclop //nolint:gocyclo,gomnd,cyclop
func (v Value) String() string { func (v Value) String() string {
switch { switch {
case v.vtype.IsArray(), v.vtype.IsAny(): case v.vtype.IsArray(), v.vtype.IsAny():
@ -62,7 +62,7 @@ func (v Value) String() string {
return fmt.Sprintf("%+v", v.AsInterface()) return fmt.Sprintf("%+v", v.AsInterface())
} }
//nolint: gocyclo,cyclop //nolint:gocyclo,cyclop
func (v Value) AsInterface() interface{} { func (v Value) AsInterface() interface{} {
switch { switch {
case v.vtype.IsArray(): case v.vtype.IsArray():

2
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 { type writer struct {
ctx context.Context ctx context.Context
level level.Level level level.Level

2
writter.go

@ -76,7 +76,7 @@ func WithJSONFormat() Option {
return WithEncode(jsonFormat) return WithEncode(jsonFormat)
} }
//nolint: forcetypeassert //nolint:forcetypeassert
func stringFormat() func(entry *entry.Entry) ([]byte, error) { func stringFormat() func(entry *entry.Entry) ([]byte, error) {
pool := sync.Pool{ pool := sync.Pool{
New: func() interface{} { New: func() interface{} {

Loading…
Cancel
Save