命令

  1. go install ./xxx/...
  2. eg : go install ./gateway/...

docker 编译

1 拉取镜像

  1. docker pull golang

2. 镜像设置

  1. go env -w GO111MODULE=on
  2. go env -w GOPROXY=https://goproxy.cn,direct
  3. go install

Docker file

  1. # 启动编译环境
  2. FROM golang:1.16
  3. # 配置编译环境
  4. go env -w GO111MODULE=on
  5. go env -w GOPROXY=https://goproxy.cn,direct
  6. # 拷贝源码到进行中
  7. # COPY source image_path
  8. COPY . /go/src/car/server
  9. # 编译
  10. WORKDIR /go/src/car/server
  11. RUN go install ./gateway/...