![如何从源代码构建 Docker Machine?(20.04)](https://linux22.com/image/933855/%E5%A6%82%E4%BD%95%E4%BB%8E%E6%BA%90%E4%BB%A3%E7%A0%81%E6%9E%84%E5%BB%BA%20Docker%20Machine%EF%BC%9F%EF%BC%8820.04%EF%BC%89.png)
我需要从源代码构建 Docker Machine。我知道最简单的方法是使用 GOPATH,但我似乎找不到如何操作?
我的机器上有 Docker Machine 源代码,但它应该在哪里编译?官方 Docker 文档没有讨论这个问题。
有人可以提供步骤吗?我正在使用 Ubuntu 20.04
编辑:在源代码目录make
中运行时 的输出:~/machine
...
...
/usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
/home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
/usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
/home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
/usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
/home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
/usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
/home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
/usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
/home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
答案1
要GOPATH
在您的机器上设置变量,请执行以下操作:
- 使用您喜欢的文本编辑器打开该
~/.profile
文件,并将以下两行添加到文件底部:
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
- 保存文件,然后重新加载您的个人资料:
$ source ~/.profile
这应该给你一个有效的GOPATH