2 usage: go command [arguments]
4 go manages Go source code.
8 build compile and install packages and dependencies
9 clean remove intermediate objects
10 fix run gofix on packages
11 fmt run gofmt -w on packages
12 get download and install packages and dependencies
13 install install packages and dependencies
16 version print Go version
17 vet run govet on packages
19 Use "go help [command]" for more information about a command.
21 Additional help topics:
23 gopath GOPATH environment variable
24 importpath description of import paths
25 remote remote import path syntax
27 Use "go help [topic]" for more information about that topic.
32 usage: go build [-n] [-v] [importpath...]
34 Build compiles the packages named by the import paths,
35 along with their dependencies, but it does not install the results.
37 The -n flag prints the commands but does not run them.
38 The -v flag prints the commands.
40 For more about import paths, see 'go help importpath'.
42 See also: go install, go get, go clean.
46 usage: go clean [-nuke] [importpath...]
48 Clean removes intermediate object files generated during
49 the compilation of the packages named by the import paths,
50 but by default it does not remove the installed package binaries.
52 The -nuke flag causes clean to remove the installed package binaries too.
54 TODO: Clean does not clean dependencies of the packages.
56 For more about import paths, see 'go help importpath'.
60 usage: go install [-n] [-v] [importpath...]
62 Install compiles and installs the packages named by the import paths,
63 along with their dependencies.
65 The -n flag prints the commands but does not run them.
66 The -v flag prints the commands.
68 For more about import paths, see 'go help importpath'.
70 See also: go build, go get, go clean.
74 usage: go fix [importpath...]
76 Fix runs the gofix command on the packages named by the import paths.
78 For more about gofix, see 'godoc gofix'.
79 For more about import paths, see 'go help importpath'.
81 To run gofix with specific options, run gofix itself.
83 See also: go fmt, go vet.
87 usage: go fmt [importpath...]
89 Fmt runs the command 'gofmt -w' on the packages named by the import paths.
91 For more about gofmt, see 'godoc gofmt'.
92 For more about import paths, see 'go help importpath'.
94 To run gofmt with specific options, run gofmt itself.
96 See also: go fix, go vet.
100 usage: go get [importpath...]
102 Get downloads and installs the packages named by the import paths,
103 along with their dependencies.
105 After downloading the code, 'go get' looks for a tag beginning
106 with "go." that corresponds to the local Go version.
107 For Go "release.r58" it looks for a tag named "go.r58".
108 For "weekly.2011-06-03" it looks for "go.weekly.2011-06-03".
109 If the specific "go.X" tag is not found, it uses the latest earlier
110 version it can find. Otherwise, it uses the default version for
111 the version control system: HEAD for git, tip for Mercurial,
114 TODO: Explain versions better.
116 For more about import paths, see 'go help importpath'.
118 For more about how 'go get' finds source code to
119 download, see 'go help remote'.
121 See also: go build, go install, go clean.
125 usage: go list [-f format] [-json] [importpath...]
127 List lists the packages named by the import paths.
129 The default output shows the package name and file system location:
131 books /home/you/src/google-api-go-client.googlecode.com/hg/books/v1
132 oauth /home/you/src/goauth2.googlecode.com/hg/oauth
133 sqlite /home/you/src/gosqlite.googlecode.com/hg/sqlite
135 The -f flag specifies an alternate format for the list,
136 using the syntax of package template. The default output
137 is equivalent to -f '{{.Name}} {{.Dir}}' The struct
138 being passed to the template is:
140 type Package struct {
141 Name string // package name
142 Doc string // package documentation string
143 GoFiles []string // names of Go source files in package
144 ImportPath string // import path denoting package
145 Imports []string // import paths used by this package
146 Deps []string // all (recursively) imported dependencies
147 Dir string // directory containing package sources
148 Version string // version of installed package
151 The -json flag causes the package data to be printed in JSON format.
153 For more about import paths, see 'go help importpath'.
157 usage: go test [importpath...]
159 Test runs gotest to test the packages named by the import paths.
160 It prints a summary of the test results in the format:
167 followed by gotest output for each failed package.
169 For more about import paths, see 'go help importpath'.
171 See also: go build, go compile, go vet.
177 Version prints the Go version, as reported by runtime.Version.
181 usage: go vet [importpath...]
183 Vet runs the govet command on the packages named by the import paths.
185 For more about govet, see 'godoc govet'.
186 For more about import paths, see 'go help importpath'.
188 To run govet with specific options, run govet itself.
190 See also: go fmt, go fix.
194 The GOPATH environment variable lists places to look for Go code.
195 On Unix, the value is a colon-separated string.
196 On Windows, the value is a semicolon-separated string.
197 On Plan 9, the value is a list.
199 GOPATH must be set to build and install packages outside the
202 Each directory listed in GOPATH must have a prescribed structure:
204 The src/ directory holds source code. The path below 'src'
205 determines the import path or executable name.
207 The pkg/ directory holds installed package objects.
208 As in the Go tree, each target operating system and
209 architecture pair has its own subdirectory of pkg
212 If DIR is a directory listed in the GOPATH, a package with
213 source in DIR/src/foo/bar can be imported as "foo/bar" and
214 has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a".
216 The bin/ directory holds compiled commands.
217 Each command is named for its source directory, but only
218 the final element, not the entire path. That is, the
219 command with source in DIR/src/foo/quux is installed into
220 DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
221 so that you can add DIR/bin to your PATH to get at the
224 Here's an example directory layout:
226 GOPATH=/home/user/gocode
231 bar/ (go code in package bar)
233 quux/ (go code in package main)
236 quux (installed command)
240 bar.a (installed package object)
242 Go searches each directory listed in GOPATH to find source code,
243 but new packages are always downloaded into the first directory
247 --- go help importpath
248 Many commands apply to a set of packages named by import paths:
250 go action [importpath...]
252 An import path that is a rooted path or that begins with
253 a . or .. element is interpreted as a file system path and
254 denotes the package in that directory.
256 Otherwise, the import path P denotes the package found in
257 the directory DIR/src/P for some DIR listed in the GOPATH
258 environment variable (see 'go help gopath').
260 If no import paths are given, the action applies to the
261 package in the current directory.
263 The special import path "all" expands to all package directories
264 found in all the GOPATH trees. For example, 'go list all'
265 lists all the packages on the local system.
267 An import path can also name a package to be downloaded from
268 a remote repository. Run 'go help remote' for details.
270 Every package in a program must have a unique import path.
271 By convention, this is arranged by starting each path with a
272 unique prefix that belongs to you. For example, paths used
273 internally at Google all begin with 'google', and paths
274 denoting remote repositories begin with the path to the code,
275 such as 'project.googlecode.com/'.
279 An import path (see 'go help importpath') denotes a package
280 stored in the local file system. Certain import paths also
281 describe how to obtain the source code for the package using
282 a revision control system.
284 A few common code hosting sites have special syntax:
286 BitBucket (Mercurial)
288 import "bitbucket.org/user/project"
289 import "bitbucket.org/user/project/sub/directory"
293 import "github.com/user/project"
294 import "github.com/user/project/sub/directory"
296 Google Code Project Hosting (Git, Mercurial, Subversion)
298 import "project.googlecode.com/git"
299 import "project.googlecode.com/git/sub/directory"
301 import "project.googlecode.com/hg"
302 import "project.googlecode.com/hg/sub/directory"
304 import "project.googlecode.com/svn/trunk"
305 import "project.googlecode.com/svn/trunk/sub/directory"
309 import "launchpad.net/project"
310 import "launchpad.net/project/series"
311 import "launchpad.net/project/series/sub/directory"
313 import "launchpad.net/~user/project/branch"
314 import "launchpad.net/~user/project/branch/sub/directory"
316 For code hosted on other servers, an import path of the form
320 specifies the given repository, with or without the .vcs suffix,
321 using the named version control system, and then the path inside
322 that repository. The supported version control systems are:
331 import "example.org/user/foo.hg"
333 denotes the root directory of the Mercurial repository at
334 example.org/user/foo or foo.hg, and
336 import "example.org/repo.git/foo/bar"
338 denotes the foo/bar directory of the Git repository at
339 example.com/repo or repo.git.
341 When a version control system supports multiple protocols,
342 each is tried in turn when downloading. For example, a Git
343 download tries git://, then https://, then http://.
345 New downloaded packages are written to the first directory
346 listed in the GOPATH environment variable (see 'go help gopath').
348 The go command attempts to download the version of the
349 package appropriate for the Go release being used.
350 Run 'go help install' for more.