1、安装go
export GOROOT=/usr/local/go
export GOPATH=/用户目录/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOBIN
export GO111MODULE="off"
验证安装:go version
2、安装最新版 golangci-lint
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
golangci-lint --version
检测项:
golangci-lint help linters
3、检测语法:https://golangci-lint.run/usage/quick-start/
以模块维度 遍历执行
获取所有的package :cd $GOPATH/src/module && go list ./...
质检语句:
cd $GOPATH/src/ && golangci-lint run moduleName/tools/ --disable-all -E deadcode,errcheck,gosimple,govet,ineffassign,staticcheck,structcheck,typecheck,unused,varcheck
执行失败兜底方案:
cd $GOPATH/src/ && golangci-lint run moduleName/tools/ --disable-all -E typecheck
es-check-tool:https://github.com/ztyezi/es-check-tool