gometalinter 正在检查 /usr/local/go 个文件
gometalinter is checking /usr/local/go files
我 运行宁 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
用户。
我在 Github 上发现了类似的问题:https://github.com/alecthomas/gometalinter/issues/149
评论 https://github.com/alecthomas/gometalinter/issues/149#issuecomment-371928626 中的解决方案对我有用:
env CGO_ENABLED=0 gometalinter ./src/main.go
我 运行宁 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
用户。
我在 Github 上发现了类似的问题:https://github.com/alecthomas/gometalinter/issues/149
评论 https://github.com/alecthomas/gometalinter/issues/149#issuecomment-371928626 中的解决方案对我有用:
env CGO_ENABLED=0 gometalinter ./src/main.go