我正在针对一个文件运行gometalinter :gometalinter ./src/main.go
但它会打印 golang 源文件的错误:
90cc5ff9b2ea:/repo# gometalinter ./src/main.go
../usr/local/go/src/net/lookup_unix.go:80:24:warning: unused struct field undeclared name: cgoLookupHost (structcheck)
../usr/local/go/src/net/lookup_unix.go:323:23:warning: undeclared name: cgoLookupPTR (interfacer)
../usr/local/go/src/net/lookup_unix.go:323:23:warning: error return value not checked (undeclared name: cgoLookupPTR) (errcheck)
../usr/local/go/src/net/lookup_unix.go:95:24:warning: error return value not checked (undeclared name: cgoLookupIP) (errcheck)
../usr/local/go/src/net/lookup_unix.go:80:24:warning: error return value not checked (undeclared name: cgoLookupHost) (errcheck)
../usr/local/go/src/net/lookup_unix.go:123:24:warning: unused struct field undeclared name: cgoLookupCNAME (structcheck)
../usr/local/go/src/net/lookup_unix.go:323:23:warning: unused variable or constant undeclared name: cgoLookupPTR (varcheck)
../usr/local/go/src/net/lookup_unix.go:80:24:warning: unused variable or constant undeclared name: cgoLookupHost (varcheck)
../usr/local/go/src/net/lookup_unix.go:95:24:warning: undeclared name: cgoLookupIP (interfacer)
../usr/local/go/src/net/lookup_unix.go:80:24:warning: undeclared name: cgoLookupHost (interfacer)
../usr/local/go/src/net/lookup_unix.go:95:24:warning: unused variable or constant undeclared name: cgoLookupIP (varcheck)
../usr/local/go/src/net/lookup_unix.go:107:23:warning: error return value not checked (undeclared name: cgoLookupPort) (errcheck)
../usr/local/go/src/net/lookup_unix.go:323:23:warning: unused struct field undeclared name: cgoLookupPTR (structcheck)
../usr/local/go/src/net/lookup_unix.go:107:23:warning: unused struct field undeclared name: cgoLookupPort (structcheck)
../usr/local/go/src/net/lookup_unix.go:123:24:warning: unused variable or constant undeclared name: cgoLookupCNAME (varcheck)
../usr/local/go/src/net/lookup_unix.go:123:24:warning: undeclared name: cgoLookupCNAME (interfacer)
../usr/local/go/src/net/lookup_unix.go:123:24:warning: error return value not checked (undeclared name: cgoLookupCNAME) (errcheck)
../usr/local/go/src/net/lookup_unix.go:95:24:warning: unused struct field undeclared name: cgoLookupIP (structcheck)
../usr/local/go/src/net/lookup_unix.go:107:23:warning: unused variable or constant undeclared name: cgoLookupPort (varcheck)
../usr/local/go/src/net/lookup_unix.go:107:23:warning: undeclared name: cgoLookupPort (interfacer)
如何仅gometalinter
针对一个文件或./src
目录运行?
我的配置:
{
"Deadline": "5m",
"EnableGC": true,
"Enable": [
"deadcode",
"gocyclo",
"gofmt",
"gotype",
"goimports",
"golint",
"gosimple",
"ineffassign",
"interfacer",
"misspell",
"unconvert",
"unused",
"vet",
"varcheck",
"maligned",
"errcheck",
"megacheck",
"goconst",
"structcheck"
],
"Cyclo": 10,
"Aggregate": true
}
该命令在 Docker 容器中以golang:alpine
用户身份启动root
。