diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000000000..332ca2bd52e97 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,34 @@ +issues: + exclude-rules: + - linters: gosimple + text: "S1002: should omit comparison to bool constant" + exclude-use-default: true + max-same-issues: 0 + max-issues-per-linter: 0 + +linters: + disable-all: true + enable: + - bodyclose + - deadcode + - goimports + - golint + - gosimple + - govet + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - varcheck + +output: + uniq-by-line: false + +run: + skip-dirs: + - vendor + skip-dirs-use-default: false + timeout: 5m diff --git a/Makefile b/Makefile index a3562de0e9b99..f00229ae7add4 100644 --- a/Makefile +++ b/Makefile @@ -44,8 +44,6 @@ CGOFLAG = CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc endif endif -GO_LINTERS ?= "unused,govet,typecheck,deadcode,goimports,varcheck,structcheck,bodyclose,staticcheck,ineffassign,unconvert,misspell,gosimple,golint" - OS ?= $(shell go env GOOS) ARCH ?= $(shell go env GOARCH) FIPS ?= @@ -293,7 +291,7 @@ integration-root: # # Lint the Go code. -# By default lint scans the entire repo. Pass FLAGS='--new' to only scan local +# By default lint scans the entire repo. Pass GO_LINT_FLAGS='--new' to only scan local # changes (or last commit). # .PHONY: lint @@ -302,17 +300,7 @@ lint: lint-sh lint-helm lint-go .PHONY: lint-go lint-go: GO_LINT_FLAGS ?= lint-go: - golangci-lint run \ - --disable-all \ - --exclude-use-default \ - --exclude='S1002: should omit comparison to bool constant' \ - --skip-dirs vendor \ - --uniq-by-line=false \ - --max-same-issues=0 \ - --max-issues-per-linter 0 \ - --timeout=5m \ - --enable $(GO_LINTERS) \ - $(GO_LINT_FLAGS) + golangci-lint run -c .golangci.yml $(GO_LINT_FLAGS) # TODO(awly): remove the `--exclude` flag after cleaning up existing scripts .PHONY: lint-sh diff --git a/build.assets/Dockerfile b/build.assets/Dockerfile index 6165c59030027..6f3e6d8d1214a 100644 --- a/build.assets/Dockerfile +++ b/build.assets/Dockerfile @@ -72,8 +72,8 @@ ENV GOPATH="/go" \ PATH="$PATH:/opt/go/bin:/go/bin:/go/src/github.com/gravitational/teleport/build" # Install meta-linter. -RUN (curl -L https://github.com/golangci/golangci-lint/releases/download/v1.24.0/golangci-lint-1.24.0-$(go env GOOS)-$(go env GOARCH).tar.gz | tar -xz && \ - cp golangci-lint-1.24.0-$(go env GOOS)-$(go env GOARCH)/golangci-lint /bin/ && \ +RUN (curl -L https://github.com/golangci/golangci-lint/releases/download/v1.38.0/golangci-lint-1.38.0-$(go env GOOS)-$(go env GOARCH).tar.gz | tar -xz && \ + cp golangci-lint-1.38.0-$(go env GOOS)-$(go env GOARCH)/golangci-lint /bin/ && \ rm -r golangci-lint*) # Install helm. diff --git a/lib/auth/middleware.go b/lib/auth/middleware.go index 511909f3b732c..ed9aa6dfb0732 100644 --- a/lib/auth/middleware.go +++ b/lib/auth/middleware.go @@ -216,9 +216,8 @@ func (t *TLSServer) Shutdown(ctx context.Context) error { func (t *TLSServer) Serve() error { errC := make(chan error, 2) go func() { - if err := t.mux.Serve(); err != nil { - t.log.WithError(err).Warningf("Mux serve failed.") - } + err := t.mux.Serve() + t.log.WithError(err).Warningf("Mux serve failed.") }() go func() { errC <- t.httpServer.Serve(t.mux.HTTP())