dongyijing2353 2019-03-31 14:52
浏览 62
已采纳

为什么参加考试突然需要“ gcc”?

I have a project that I upgraded FROM golang:1.9-alpine to FROM golang:1.12-alpine and now my test aren't running. It's now saying:

$ docker-compose exec bot go vet       
# runtime/cgo
exec: "gcc": executable file not found in $PATH

According to the docs for https://golang.org/doc/install/gccgo this is the compiler. How come I can run my app without this but it won't run tests without it? I've been looking through the change logs and must be missing where this is covered.

Here's my Dockerfile:

FROM golang:1.12-alpine
RUN mkdir /app
WORKDIR /app
ADD src/ /app

# Fetch application dependencies
RUN apk add --no-cache --update git \
    && go get github.com/bwmarrin/discordgo \
    && go get github.com/jonas747/dshardmanager \
    && go get github.com/bugsnag/bugsnag-go \
    && apk del git

# Build binary
RUN go build -o main .

CMD ["/app/main"]
  • 写回答

1条回答 默认 最新

  • dongzhang1864 2019-03-31 15:11
    关注

    It looks like you're encountering this issue: https://github.com/golang/go/issues/26988

    The workaround suggested is to set these environment variables when building:

    CGO_ENABLED=0 GO111MODULE=off
    

    You might also prefer a multi-stage docker build, so that your final docker image is minimal (for example, not including the source files you've compiled from, and the go compiler). An example from the docker documentation is here: https://docs.docker.com/develop/develop-images/multistage-build/

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

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘