github.com/rogpeppe/godep@v0.0.0-20140525002653-983ff9241cea/Readme.md (about) 1 ### Godep 2 3 Command godep helps build packages reproducibly by fixing their dependencies. 4 5 This tool assumes you are working in a standard Go workspace, 6 as described in http://golang.org/doc/code.html. We require Go 1.1 7 or newer to build godep itself, but you can use it on any project 8 that works with Go 1 or newer. 9 10 ### Install 11 12 $ go get github.com/tools/godep 13 14 #### Getting Started 15 16 How to add godep in a new project. 17 18 Assuming you've got everything working already, so you can 19 build your project with `go install` and test it with `go test`, 20 it's one command to start using: 21 22 $ godep save 23 24 This will save a list of dependencies to the file Godeps/Godeps.json, 25 and copy their source code into Godeps/_workspace. 26 Read over its contents and make sure it looks reasonable. 27 Then commit the file to version control. 28 29 You can omit the source code with the flag -copy=false. 30 This means fewer files to store in your local repository, but 31 subsequent invocations of `godep go` will need to access the 32 network to fetch the appropriate source code later. Using the 33 default behavior is faster and more reliable. 34 35 #### Edit-test Cycle 36 37 1. Edit code 38 2. Run `godep go test` 39 3. (repeat) 40 41 #### Add or Update a Dependency 42 43 To add or update package foo/bar, do this: 44 45 1. Run `godep restore` 46 2. Run `go get -u foo/bar` 47 3. Edit your code, if necessary, to import foo/bar. 48 4. Run `godep save` 49 50 Before committing the change, you'll probably want to inspect 51 the changes to Godeps, for example with `git diff`, 52 and make sure it looks reasonable. 53 54 #### Multiple Packages 55 56 If your repository has more than one package, you're probably 57 accustomed to running commands like `go test ./...`, 58 `go install ./...`, and `go fmt ./...`. 59 Similarly, you should run `godep save ./...` to capture the 60 dependencies of all packages. 61 62 #### Using Other Tools 63 64 The `godep path` command helps integrate with commands other 65 than the standard go tool. This works with any tool that reads 66 GOPATH from its environment, for example the recently-released 67 [oracle command](http://godoc.org/code.google.com/p/go.tools/cmd/oracle). 68 69 $ GOPATH=`godep path`:$GOPATH 70 $ oracle -mode=implements . 71 72 ### File Format 73 74 Godeps is a json file with the following structure: 75 76 ```go 77 type Godeps struct { 78 ImportPath string 79 GoVersion string // Abridged output of 'go version'. 80 Packages []string // Arguments to godep save, if any. 81 Deps []struct { 82 ImportPath string 83 Comment string // Description of commit, if present. 84 Rev string // VCS-specific commit ID. 85 } 86 } 87 ``` 88 89 Example Godeps: 90 91 ```json 92 { 93 "ImportPath": "github.com/kr/hk", 94 "GoVersion": "go1.1.2", 95 "Deps": [ 96 { 97 "ImportPath": "code.google.com/p/go-netrc/netrc", 98 "Rev": "28676070ab99" 99 }, 100 { 101 "ImportPath": "github.com/kr/binarydist", 102 "Rev": "3380ade90f8b0dfa3e363fd7d7e941fa857d0d13" 103 } 104 ] 105 } 106 ```