【发布时间】:2013-12-02 18:22:56
【问题描述】:
如何从源代码构建 Go 项目,而不是使用 go get domain.com/dir/project?例如,而不是
go get github.com/kr/godep
我想从源代码构建:
git clone https://github.com/kr/godep.git
cd godep
GOPATH=/tmp/godep go build
上面的命令会导致
dep.go:4:2: cannot find package "code.google.com/p/go.tools/go/vcs" in any of:
/usr/local/Cellar/go/1.2/libexec/src/pkg/code.google.com/p/go.tools/go/vcs (from $GOROOT)
/Users/hanxue/Source/godep/godep/src/code.google.com/p/go.tools/go/vcs (from $GOPATH)
save.go:5:2: cannot find package "github.com/kr/fs" in any of:
/usr/local/Cellar/go/1.2/libexec/src/pkg/github.com/kr/fs (from $GOROOT)
/Users/hanxue/Source/godep/godep/src/github.com/kr/fs (from $GOPATH)
注意:go 1.2 安装在 /usr/local/Cellar/go/1.2 中,并带有从/usr/local/Cellar/go/1.2/bin/go 到/usr/local/bin/go 的链接
【问题讨论】:
-
你必须手动安装
code.google.com/p/go.tools/go/vcs等所有依赖项,请仔细设置GOPATHcode.google.com/p/go-wiki/wiki/GOPATH -
@hanxue 很好奇,用 go get 有什么问题?
-
@nemo 没什么错,实际上这是构建 Go 项目的最佳方式。我想从源代码构建,以便我可以创建自制公式
-
@hanxue 啊,解释了。感谢您的澄清。