Skip to content

Commit

Permalink
chore: fix linter (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma authored May 26, 2021
1 parent a7d44ab commit 3492175
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 18 deletions.
27 changes: 16 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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

issues:
exclude-use-default: false
exclude-rules:
- path: internal/bytes/buffer.go
linters:
- govet
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions ctx/ctx.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package ctx implements log context convenience functions.
package ctx

import (
Expand Down
2 changes: 1 addition & 1 deletion format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestJsonFormat_Strings(t *testing.T) {
},
{
name: "tab",
in: "bar baz",
in: "bar baz",
want: `"bar\tbaz"`,
},
{
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestLogfmtFormat_Strings(t *testing.T) {
},
{
name: "tab",
in: "bar baz",
in: "bar baz",
want: `"bar\tbaz"`,
},
{
Expand Down Expand Up @@ -354,7 +354,7 @@ func TestConsoleFormat_Strings(t *testing.T) {
},
{
name: "tab",
in: "bar baz",
in: "bar baz",
want: `bar\tbaz`,
},
{
Expand Down
1 change: 1 addition & 0 deletions internal/bytes/buffer.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package bytes implements performant bytes implementations.
package bytes

import (
Expand Down
1 change: 1 addition & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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())
}

Expand Down

0 comments on commit 3492175

Please sign in to comment.