我已经创建了以下 docker 容器,除了 make lint 之外的所有东西都可以工作
在项目根目录中,我有包含当前条目的Makefile
lint:
gometalinter --config=gometalinter.json ./...
当我在我的机器 (macbook) 本地使用它时,如果例如文件未格式化 go fmt
我在执行上面的代码时出错。
问题是,当我通过 docker build 命令
我遇到了与我的项目无关的不同 linting 问题。
在 gometalinter.json
中,我有以下条目来绕过 vendor 目录
{
"vendor": true
}
这是docker内容
FROM golang:1.11.1-alpine3.7
RUN apk add --update --no-cache git make curl bash
ADD https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep
WORKDIR /go/src/my-proj
COPY . ./
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure
# From the error it seems that this is related to cgo but even adding the next line doesnt helps, same error occurred
RUN CGO_ENABLED=0
# this command download gometalinter which is running OK
RUN make download
RUN make lint
当我运行 lint 时,这是我得到的,与我的项目无关
../../../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:95:24:warning: error return value not checked (undeclared name: cgoLookupIP) (errcheck)
../../../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:123:24:warning: error return value not checked (undeclared name: cgoLookupCNAME) (errcheck)
../../../usr/local/go/src/net/lookup_unix.go:323:23:warning: error return value not checked (undeclared name: cgoLookupPTR) (errcheck)
最佳答案
关于docker - 使用 lint 命令构建 docker go 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53750330/