执行git
go get github.com/tools/godep
godep version
mkdir Project cd Project git init .
go get foo/bar
编写代码使用依赖项。github
godep save
godep go test
git init . git add . git commit -a -m "Initial commit."
godep save
godep会将工程依赖项复制到工程目录的vendor/子目录下。在这个过程当中,如下文件不会复制json
godep restore将Godeps/Godeps.json文件中指定的包安装到$GOPATH目录。ide
go get -u foo/bar godep update foo/bar
Godeps.json文件描述了工程依赖项。Godeps.json文件位于工程目录的字母Godeps下。测试
type Godeps struct { ImportPath string GoVersion string // Abridged output of 'go version'. GodepVersion string // Abridged output of 'godep version' Packages []string // Arguments to godep save, if any. Deps []struct { ImportPath string Comment string // Description of commit, if present. Rev string // VCS-specific commit ID. } }
{ "ImportPath": "github.com/kr/hk", "GoVersion": "go1.6", "Deps": [ { "ImportPath": "code.google.com/p/go-netrc/netrc", "Rev": "28676070ab99" }, { "ImportPath": "github.com/kr/binarydist", "Rev": "3380ade90f8b0dfa3e363fd7d7e941fa857d0d13" } ] }
godep: [WARNING]: godep should only be used inside a valid go package directory and godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH. godep: [WARNING]: Current Directory: D:\Workspace\Develop\AHStock godep: [WARNING]: $GOPATH: D:\Workspace\GoWorkspacegoogle
缘由是工程目录不是$GOPATH的子目录。spa