Skip to content

Instantly share code, notes, and snippets.

@spyzhov
Last active April 9, 2019 08:33
Show Gist options
  • Save spyzhov/2392593aaf8d8ed6b7e4fa3e70a49b1f to your computer and use it in GitHub Desktop.
Save spyzhov/2392593aaf8d8ed6b7e4fa3e70a49b1f to your computer and use it in GitHub Desktop.
Golang checker for a several linters
#!/usr/bin/env bash
BIN="${GOPATH}/bin"
if [[ "$(which go)" == "" ]]; then
echo "Install GoLang first..."
exit 1
fi
if [[ "$(which gofmt)" == "" ]]; then
echo "Install GoLang with gofmt first..."
exit 1
fi
if [[ "$(which golint)" == "" ]]; then
echo "Installing golint..."
echo "sudo apt install golint"
sudo apt install golint
fi
if [[ "$(which errcheck)" == "" && ! -f "${BIN}/errcheck" ]]; then
echo "Installing errcheck..."
echo "go get -u github.com/kisielk/errcheck"
go get -u github.com/kisielk/errcheck
fi
if [[ "$(which golangci-lint)" == "" && ! -f "${BIN}/golangci-lint" ]]; then
echo "Installing golangci-lint..."
echo "go get -u github.com/golangci/golangci-lint/cmd/golangci-lint"
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
fi
if [[ "$(which gocyclo)" == "" && ! -f "${BIN}/gocyclo" ]]; then
echo "Installing gocyclo..."
echo "go get -u github.com/fzipp/gocyclo"
go get -u github.com/fzipp/gocyclo
fi
echo "Run tests..."
go test -race ./...
echo "...done..."
sleep 3
echo "Run fmt..."
gofmt -d -e -s .
echo "...done..."
sleep 3
echo "Run go vet..."
go vet .
echo "...done..."
sleep 3
echo "Run golint..."
golint .
echo "...done..."
sleep 3
echo "Run errcheck..."
errcheck .
echo "...done..."
sleep 3
echo "Run golangci-lint..."
golangci-lint run
echo "...done..."
sleep 3
echo "Run gocyclo..."
gocyclo -top 10 .
echo "...done..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment