dongwu4834 2018-12-12 11:46
浏览 123
已采纳

使用lint命令构建docker go应用

I've created the following docker container , all works except on thing which is the make lint

In the project root I've Makefile with the current entry

lint:
    gometalinter --config=gometalinter.json ./...

when I use it locally in my machine (macbook) and if for example file is not formatted go fmt I get error when executing above code.

The problem is that when I create the docker image via docker build command

I got different linting issues which is not related to my project. in the gometalinter.json I've the following entry to bypass the vendor directory

{
  "vendor": true
}

This is the docker content

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

when I run the lint this is what I got which is not related to my project

../../../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)

展开全部

  • 写回答

1条回答 默认 最新

  • douyou8266 2018-12-12 15:36
    关注

    You are not correctly setting the environment variable in your Dockerfile.

    RUN CGO_ENABLED=0

    should be

    ENV CGO_ENABLED=0

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥20 macmin m 4连接iPad
  • ¥15 DBIF_REPO_SQL_ERROR
  • ¥15 根据历年月数据,用Stata预测未来六个月汇率
  • ¥15 DevEco studio开发工具 真机联调找不到手机设备
  • ¥15 请教前后端分离的问题
  • ¥100 冷钱包突然失效,急寻解决方案
  • ¥15 下载honeyd时报错 configure: error: you need to instal a more recent version of libdnet
  • ¥15 距离软磁铁一定距离的磁感应强度大小怎么求
  • ¥15 霍尔传感器hmc5883l的xyz轴输出和该点的磁感应强度大小的关系是什么
  • ¥15 vscode开发micropython,import模块出现异常
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部