diff --git a/.golangci.yml b/.golangci.yml index 2b07dfd..121e9ef 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,30 +1,35 @@ run: tests: false - timeout: 5m + deadline: 5m + linters-settings: cyclop: max-complexity: 12 skip-tests: true + gofumpt: + extra-rules: true + linters: enable-all: true disable: + - interfacer # deprecated + - scopelint # deprecated + - maligned # deprecated + - golint # deprecated - exhaustive - exhaustivestruct - forcetypeassert - gochecknoglobals - gochecknoinits - - gocognit - - gocyclo - goerr113 - - golint - gomnd - - interfacer - - maligned - - nestif - - noctx - nlreturn - - scopelint - wrapcheck - wsl - - gofumpt - - godox \ No newline at end of file + +issues: + exclude-use-default: false + exclude-rules: + - path: internal/bytes/buffer.go + linters: + - govet diff --git a/LICENCE b/LICENCE index 597a1a4..077af63 100644 --- a/LICENCE +++ b/LICENCE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Nicholas Wiersma +Copyright (c) 2021 Nicholas Wiersma Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/ctx/ctx.go b/ctx/ctx.go index baf59e2..ceb0ba1 100644 --- a/ctx/ctx.go +++ b/ctx/ctx.go @@ -1,3 +1,4 @@ +// Package ctx implements log context convenience functions. package ctx import ( diff --git a/format.go b/format.go index 96337a7..fbff65d 100644 --- a/format.go +++ b/format.go @@ -284,7 +284,7 @@ func (c *console) AppendArrayEnd(_ *bytes.Buffer) {} func (c *console) AppendKey(buf *bytes.Buffer, key string) { buf.WriteByte(' ') - var col = newColor(colorCyan) + col := newColor(colorCyan) if strings.HasPrefix(key, "err") { col = newColor(colorRed) } diff --git a/format_test.go b/format_test.go index a325497..f66ca70 100644 --- a/format_test.go +++ b/format_test.go @@ -56,7 +56,7 @@ func TestJsonFormat_Strings(t *testing.T) { }, { name: "tab", - in: "bar baz", + in: "bar baz", want: `"bar\tbaz"`, }, { @@ -205,7 +205,7 @@ func TestLogfmtFormat_Strings(t *testing.T) { }, { name: "tab", - in: "bar baz", + in: "bar baz", want: `"bar\tbaz"`, }, { @@ -354,7 +354,7 @@ func TestConsoleFormat_Strings(t *testing.T) { }, { name: "tab", - in: "bar baz", + in: "bar baz", want: `bar\tbaz`, }, { diff --git a/internal/bytes/buffer.go b/internal/bytes/buffer.go index d9aec22..d2a1297 100644 --- a/internal/bytes/buffer.go +++ b/internal/bytes/buffer.go @@ -1,3 +1,4 @@ +// Package bytes implements performant bytes implementations. package bytes import ( diff --git a/logger.go b/logger.go index ce7edd1..5cf5993 100644 --- a/logger.go +++ b/logger.go @@ -57,6 +57,7 @@ func (l Level) String() string { // Field is a context field. type Field func(*Event) +// Logger is a logger. type Logger struct { w io.Writer fmtr Formatter diff --git a/logger_test.go b/logger_test.go index 0207d51..35c5db9 100644 --- a/logger_test.go +++ b/logger_test.go @@ -186,7 +186,7 @@ func TestLogger_Context(t *testing.T) { log := logger.New(&buf, logger.LogfmtFormat(), logger.Info).With(ctx.Str("_n", "bench"), ctx.Int("_p", 1)) _, file, line, _ := runtime.Caller(0) - caller := file+":"+strconv.Itoa(line+3) + caller := file + ":" + strconv.Itoa(line+3) log.Info("some message", ctx.Str("str", "string"), @@ -213,7 +213,7 @@ func TestLogger_Context(t *testing.T) { ctx.Caller("caller"), ) - want := `lvl=info msg="some message" _n=bench _p=1 str=string strs=string1,string2 bytes=98,121,116,101,115 bool=true int=1 ints=1,2,3 int8=2 int16=3 int32=4 int64=5 uint=1 uint8=2 uint16=3 uint32=4 uint64=5 float32=1.230 float64=4.560 err="test error" str=2018-11-07T06:54:30+0000 str=1s str={Name:test} caller=`+caller + "\n" + want := `lvl=info msg="some message" _n=bench _p=1 str=string strs=string1,string2 bytes=98,121,116,101,115 bool=true int=1 ints=1,2,3 int8=2 int16=3 int32=4 int64=5 uint=1 uint8=2 uint16=3 uint32=4 uint64=5 float32=1.230 float64=4.560 err="test error" str=2018-11-07T06:54:30+0000 str=1s str={Name:test} caller=` + caller + "\n" assert.Equal(t, want, buf.String()) }