如何轻松使用格式化和静态检查工具
make fmt make lint
1、go.mod 同级目录创建文件 Makefile
fmt: command -v gofumpt || (WORK=$(shell pwd) && cd /tmp && GO111MODULE=on go install mvdan.cc/gofumpt@latest && cd $(WORK)) gofumpt -w -d . lint: command -v golangci-lint || (WORK=$(shell pwd) && cd /tmp && GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/[email protected] && cd $(WORK)) golangci-lint run -v
2、go.mod 同级目录创建文件 .golangci.toml
[run] tests = false concurrency = 4 skip-dirs = [ "vendor", "go" ] timeout= "300s" [run.output] format = "tab" [linters] disable-all = true enable = [ "unconvert", "megacheck", # "gosec", # "gocyclo", "dupl", "misspell", "unparam", "unused", # "deadcode", "typecheck", "ineffassign", "gochecknoinits", "gocritic", # "godox", "gofmt", "gofumpt", "goimports", # "lll", ] # linter config [linters-settings.dupl] threshold = 300 [linters-settings.gocritic] enabled-tags = [ "diagnostic", "experimental", "opinionated", "performance", "style", ] disabled-checks = [ "dupImport", "ifElseChain", "octalLiteral", "whyNoLint", "wrapperFunc", "paramTypeCombine", "nilValReturn", "unnamedResult", "unnecessaryBlock", "commentedOutCode", "appendCombine", "truncateCmp", "yodaStyleExpr", ]
标签:golangci,fmt,lint,cd,golang,&&,go From: https://www.cnblogs.com/xuweiqiang/p/16886255.html