diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..d59c99b --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,39 @@ +linters: + enable-all: false + disable-all: true + fast: false + enable: + - bodyclose + - dogsled + - dupl + - errcheck + - exportloopref + - exhaustive + - gochecknoinits + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + - lll + - misspell + - nakedret + - noctx + - nolintlint + - rowserrcheck + - staticcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - whitespace + - gofumpt + +run: + timeout: 3m diff --git a/zap.go b/zap.go index b0d631e..b6b155f 100644 --- a/zap.go +++ b/zap.go @@ -138,7 +138,8 @@ func CustomRecoveryWithZap(logger ZapLogger, stack bool, recovery gin.RecoveryFu var brokenPipe bool if ne, ok := err.(*net.OpError); ok { if se, ok := ne.Err.(*os.SyscallError); ok { - if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") { + if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || + strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") { brokenPipe = true } } diff --git a/zap_test.go b/zap_test.go index 6307c2e..be1cbad 100644 --- a/zap_test.go +++ b/zap_test.go @@ -14,10 +14,6 @@ import ( "go.uber.org/zap/zaptest/observer" ) -func init() { - gin.SetMode(gin.TestMode) -} - func buildDummyLogger() (*zap.Logger, *observer.ObservedLogs) { core, obs := observer.New(zap.InfoLevel) logger := zap.New(core)