chore: add golangci-lint config file (#2519)

* chore: add golangci-lint config file

* chore: member alignment
master
Kevin Wan 2 years ago committed by GitHub
parent 776673d57d
commit d4c9fd2aff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,64 @@
linters-settings:
errcheck:
check-type-assertions: true
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
check-shadowing: true
enable:
- fieldalignment
nolintlint:
require-explanation: true
require-specific: true
staticcheck:
checks:
- all
- '-SA5008'
linters:
disable-all: true
enable:
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
- exhaustive
- goconst
- gocritic
- gofmt
- goimports
- gomnd
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nolintlint
- nakedret
- prealloc
- predeclared
- revive
- staticcheck
- stylecheck
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- whitespace
- wsl
run:
issues-exit-code: 1

@ -105,7 +105,6 @@ d = "abcd!@#112"
assert.Equal(t, 1, val.B) assert.Equal(t, 1, val.B)
assert.Equal(t, "2", val.C) assert.Equal(t, "2", val.C)
assert.Equal(t, "abcd!@#112", val.D) assert.Equal(t, "abcd!@#112", val.D)
} }
func TestConfigJsonEnv(t *testing.T) { func TestConfigJsonEnv(t *testing.T) {

@ -60,8 +60,8 @@ type TokenLimiter struct {
timestampKey string timestampKey string
rescueLock sync.Mutex rescueLock sync.Mutex
redisAlive uint32 redisAlive uint32
rescueLimiter *xrate.Limiter
monitorStarted bool monitorStarted bool
rescueLimiter *xrate.Limiter
} }
// NewTokenLimiter returns a new TokenLimiter that allows events up to rate and permits // NewTokenLimiter returns a new TokenLimiter that allows events up to rate and permits

@ -361,7 +361,6 @@ func writePlainText(writer io.Writer, level, msg string, fields ...string) {
if _, err := writer.Write(buf.Bytes()); err != nil { if _, err := writer.Write(buf.Bytes()); err != nil {
log.Println(err.Error()) log.Println(err.Error())
} }
} }
func writePlainValue(writer io.Writer, level string, val interface{}, fields ...string) { func writePlainValue(writer io.Writer, level string, val interface{}, fields ...string) {

@ -139,7 +139,6 @@ func (u *Unmarshaler) processAnonymousFieldOptional(field reflect.StructField, v
filled = true filled = true
maybeNewValue(field, value) maybeNewValue(field, value)
indirectValue = reflect.Indirect(value) indirectValue = reflect.Indirect(value)
} }
if err = u.processField(subField, indirectValue.Field(i), m, fullName); err != nil { if err = u.processField(subField, indirectValue.Field(i), m, fullName); err != nil {
return err return err

@ -86,7 +86,7 @@ func TestThenOrdersHandlersCorrectly(t *testing.T) {
chained := New(t1, t2, t3).Then(testApp) chained := New(t1, t2, t3).Then(testApp)
w := httptest.NewRecorder() w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "/", nil) r, err := http.NewRequest("GET", "/", http.NoBody)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -103,7 +103,7 @@ func TestAppendAddsHandlersCorrectly(t *testing.T) {
h := c.Then(testApp) h := c.Then(testApp)
w := httptest.NewRecorder() w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "/", nil) r, err := http.NewRequest("GET", "/", http.NoBody)
assert.Nil(t, err) assert.Nil(t, err)
h.ServeHTTP(w, r) h.ServeHTTP(w, r)

@ -238,7 +238,7 @@ func TestEngine_notFoundHandler(t *testing.T) {
client := ts.Client() client := ts.Client()
err := func(ctx context.Context) error { err := func(ctx context.Context) error {
req, err := http.NewRequest("GET", ts.URL+"/bad", nil) req, err := http.NewRequest("GET", ts.URL+"/bad", http.NoBody)
assert.Nil(t, err) assert.Nil(t, err)
res, err := client.Do(req) res, err := client.Do(req)
assert.Nil(t, err) assert.Nil(t, err)
@ -261,7 +261,7 @@ func TestEngine_notFoundHandlerNotNil(t *testing.T) {
client := ts.Client() client := ts.Client()
err := func(ctx context.Context) error { err := func(ctx context.Context) error {
req, err := http.NewRequest("GET", ts.URL+"/bad", nil) req, err := http.NewRequest("GET", ts.URL+"/bad", http.NoBody)
assert.Nil(t, err) assert.Nil(t, err)
res, err := client.Do(req) res, err := client.Do(req)
assert.Nil(t, err) assert.Nil(t, err)
@ -285,8 +285,8 @@ func TestEngine_notFoundHandlerNotNilWriteHeader(t *testing.T) {
defer ts.Close() defer ts.Close()
client := ts.Client() client := ts.Client()
err := func(ctx context.Context) error { err := func(_ context.Context) error {
req, err := http.NewRequest("GET", ts.URL+"/bad", nil) req, err := http.NewRequest("GET", ts.URL+"/bad", http.NoBody)
assert.Nil(t, err) assert.Nil(t, err)
res, err := client.Do(req) res, err := client.Do(req)
assert.Nil(t, err) assert.Nil(t, err)

@ -200,7 +200,7 @@ func (w *tracedResponseWriter) Write(bytes []byte) (n int, err error) {
n, err = w.builder.Write(bytes) n, err = w.builder.Write(bytes)
if w.lessWritten { if w.lessWritten {
n -= 1 n--
} }
w.hasBody = true w.hasBody = true

Loading…
Cancel
Save