Skip to content

Instantly share code, notes, and snippets.

@stevemcquaid
Created June 16, 2020 21:57
Show Gist options
  • Save stevemcquaid/4df56990daaced764101f425667efa5f to your computer and use it in GitHub Desktop.
Save stevemcquaid/4df56990daaced764101f425667efa5f to your computer and use it in GitHub Desktop.
# Lint the Code (Run static-analysis
FROM builder as linter
WORKDIR /workspace
ARG GO111MODULE=on
# Install deps
RUN go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.26.0
RUN go get honnef.co/go/tools/cmd/staticcheck@2020.1.4
# Fail if any files are needing to be gofmt'd
RUN fmtFiles=$(go fmt ./...); test -z $fmtFiles || (echo "**** Need to run go fmt on: $fmtFiles ****" && exit 1)
RUN go vet ./...
RUN golangci-lint run \
--deadline=30m \
--disable-all \
--no-config \
--issues-exit-code=1 \
--enable=bodyclose \
--enable=deadcode \
--enable=dupl \
--enable=errcheck \
--enable=gocognit \
--enable=goconst \
--enable=gocyclo \
--enable=gofmt \
--enable=goimports \
--enable=golint \
--enable=gomodguard \
--enable=gosec \
--enable=govet \
--enable=ineffassign \
--enable=interfacer \
--enable=megacheck \
--enable=misspell \
--enable=nakedret \
--enable=prealloc \
--enable=rowserrcheck \
--enable=staticcheck \
--enable=structcheck \
--enable=stylecheck \
--enable=typecheck \
--enable=unconvert \
--enable=unparam \
--enable=varcheck \
--enable=whitespace
RUN staticcheck -fail -tests -checks all ./...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment