【问题标题】:Missing Git command when calling `go get`调用“go get”时缺少 Git 命令
【发布时间】:2019-05-11 01:40:42
【问题描述】:

我的 Dockerfile

FROM golang:1.10.2-alpine3.7 AS build
RUN apk --no-cache add gcc g++ make ca-certificates
RUN apk add git
WORKDIR /go/src/github.com/meower

COPY Gopkg.lock Gopkg.toml ./
COPY util util
COPY event event
COPY db db
COPY search search
COPY schema schema
COPY meow-service meow-service
COPY query-service query-service
COPY pusher-service pusher-service

RUN go get -d -v ./...
RUN go install ./...

FROM alpine:3.7
WORKDIR /usr/bin
COPY --from=build /go/bin .

我添加了 apk add git 行。没有此行,我的 docker-compose up 生成了

Step 13/17 : RUN go get -d -v ./...
 ---> Running in d917adba00cd
github.com/lib/pq (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/lib/pq: exec: "git": executable file not found in $PATH
github.com/nats-io/go-nats (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/nats-io/go-nats: exec: "git": executable file not found in $PATH
github.com/gorilla/mux (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/mux: exec: "git": executable file not found in $PATH
github.com/kelseyhightower/envconfig (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/kelseyhightower/envconfig: exec: "git": executable file not found in $PATH
package github.com/retry: invalid github.com/ import path "github.com/retry"
github.com/segmentio/ksuid (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/segmentio/ksuid: exec: "git": executable file not found in $PATH
github.com/gorilla/websocket (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/websocket: exec: "git": executable file not found in $PATH
github.com/olivere/elastic (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/olivere/elastic: exec: "git": executable file not found in $PATH

使用git line,其他问题依旧存在

docker-compose up
Building pusher
Step 1/18 : FROM golang:1.10.2-alpine3.7 AS build
 ---> 44ccce322b34
Step 2/18 : RUN apk --no-cache add gcc g++ make ca-certificates
 ---> Using cache
 ---> 088fa5ba19a9
Step 3/18 : RUN apk add git
 ---> Running in 01022f57861b
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  git (missing):

这是什么意思?

【问题讨论】:

    标签: go package


    【解决方案1】:

    go get 在内部调用特定 VCS 的“参考”客户端工具,该 VCS 用于托管要获取的包。换句话说,go get 本身并不知道如何与 VCS 服务器交互。

    所以是的,为了go get 一个由 Git 托管的包,您需要提供可调用的 git 二进制文件的工作 Git 安装。

    至于你的第二个问题,它是does not appear to have anything related to Go,所以我建议你做一些研究,然后再问一个标记为alpine 的单独问题,如果失败了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-10
      • 1970-01-01
      • 2021-05-27
      • 2017-03-12
      • 1970-01-01
      • 2022-11-30
      • 2016-06-12
      相关资源
      最近更新 更多