dockerfile:
FROM golang:1.16 as builder
#环境变量
ENV CGO_ENABLED=1
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
ENV GOOS=linux
ENV GOARCH=arm
ENV CC=arm-linux-gnueabi-gcc
RUN apt-get update
RUN apt-get install gcc-arm-linux-gnueabi -y
VOLUME /root/project
WORKDIR /root/project
RUN pwd
shell
docker build -t pack/golang/arm .
windows cgo
FROM golang:1.16 as builder
#环境变量
ENV CGO_ENABLED=1
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
ENV GOOS=windows
ENV GOARCH=amd64
ENV CC=x86_64-w64-mingw32-gcc
RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN sed -i s@/security.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get update
RUN apt-get install gcc-mingw-w64 -y
VOLUME /root/project
WORKDIR /root/project
RUN pwd
// 不显示GUI
go build -o xxx.exe -ldflags "-H windowsgui" -gcflags "all=-N -l" .