1
.\" Hey, EMACS: -*- nroff -*-
2
.de Vb \" Begin verbatim text
7
.de Ve \" End verbatim text
11
.TH GO-PATH 7 "2012-05-13"
12
.\" Please adjust this date whenever revising the manpage.
14
go \- tool for managing Go source code
16
The Go path is used to resolve import statements.
17
It is implemented by and documented in the go/build package.
19
The GOPATH environment variable lists places to look for Go code.
20
On Unix, the value is a colon-separated string.
21
On Windows, the value is a semicolon-separated string.
22
On Plan 9, the value is a list.
24
GOPATH must be set to build and install packages outside the
27
Each directory listed in GOPATH must have a prescribed structure:
29
The src/ directory holds source code. The path below 'src'
30
determines the import path or executable name.
32
The pkg/ directory holds installed package objects.
33
As in the Go tree, each target operating system and
34
architecture pair has its own subdirectory of pkg
37
If DIR is a directory listed in the GOPATH, a package with
38
source in DIR/src/foo/bar can be imported as "foo/bar" and
39
has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a".
41
The bin/ directory holds compiled commands.
42
Each command is named for its source directory, but only
43
the final element, not the entire path. That is, the
44
command with source in DIR/src/foo/quux is installed into
45
DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
46
so that you can add DIR/bin to your PATH to get at the
47
installed commands. If the GOBIN environment variable is
48
set, commands are installed to the directory it names instead
51
Here's an example directory layout:
54
\& GOPATH=/home/user/gocode
59
\& bar/ (go code in package bar)
61
\& quux/ (go code in package main)
64
\& quux (installed command)
68
\& bar.a (installed package object)
71
Go searches each directory listed in GOPATH to find source code,
72
but new packages are always downloaded into the first directory
76
This manual page was written by Michael Stapelberg <stapelberg@debian.org>,
77
for the Debian project (and may be used by others).