代码之家  ›  专栏  ›  技术社区  ›  Kirill

gometalinter正在检查/usr/local/go文件

  •  0
  • Kirill  · 技术社区  · 6 年前

    我在跑步 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
    }
    

    golang:alpine 作为 root 用户。

    1 回复  |  直到 6 年前
        1
  •  0
  •   Kirill    6 年前

    我在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