blob: 3cea5b3fc41db47bd64f38039aef596eb544c577 [file] [log] [blame] [view]
forskningb96b2bf2019-03-24 14:20:15 -05001This wiki page documents the file tree for a source installation of go1.9.2 to which have been added the github.com/golang blog, net and tools sub-repositories, and the github.com/gonum/gonum repository. It is somewhat consistent with the file tree of the golang.org/dl pre-compiled downloads for GNU/Linux. It presumes the reader is familiar with utilisation of $GOPATH on Un*x as a colon-separated string; GNU/Linux being a multi-user OS the added sub-repositories and repository are located in $HOME/go and /usr/share/gocode.
jimmyfrasched3f12812017-10-05 15:36:01 -07002
forskningb96b2bf2019-03-24 14:20:15 -05003```
4% tree -d -L 2 /usr/lib/go1.9.2 | head
5/usr/lib/go1.9.2
6`-- go
7 |-- api
8 |-- bin
9 |-- doc
10 |-- lib
11 |-- misc
12 |-- pkg
13 |-- src
14 `-- test
15%
16```
jimmyfrasche4b647142017-10-05 16:12:10 -070017
forskningb96b2bf2019-03-24 14:20:15 -050018api contains data for Go's API checker
jimmyfrasche4b647142017-10-05 16:12:10 -070019
forskningb96b2bf2019-03-24 14:20:15 -050020```
21% ls $GOROOT/api
22README go1.1.txt go1.3.txt go1.5.txt go1.7.txt go1.9.txt next.txt
23except.txt go1.2.txt go1.4.txt go1.6.txt go1.8.txt go1.txt
24%
25```
jimmyfrasche4b647142017-10-05 16:12:10 -070026
forskningb96b2bf2019-03-24 14:20:15 -050027bin contains the go and gofmt executables
jimmyfrasche4b647142017-10-05 16:12:10 -070028
forskningb96b2bf2019-03-24 14:20:15 -050029```
30% ls -l $GOROOT/bin
31total 7588
32-rwxr-xr-x 1 root root 5918348 Oct 31 16:06 go
33-rwxr-xr-x 1 root root 1831140 Oct 31 16:06 gofmt
34%
35```
jimmyfrasche4b647142017-10-05 16:12:10 -070036
forskningb96b2bf2019-03-24 14:20:15 -050037doc contains .css, .go, .html, .js, and .png files
jimmyfrasche4b647142017-10-05 16:12:10 -070038
forskningb96b2bf2019-03-24 14:20:15 -050039lib contains the compressed time zone database
jimmyfrasche4b647142017-10-05 16:12:10 -070040
forskningb96b2bf2019-03-24 14:20:15 -050041```
42% tree $GOROOT/lib | head -n 5
43/usr/lib/go1.9.2/go/lib
44`-- time
45|-- README
46|-- update.bash
47`-- zoneinfo.zip
48%
49```
jimmyfrasche4b647142017-10-05 16:12:10 -070050
forskningb96b2bf2019-03-24 14:20:15 -050051misc/android contains information on development for android<br/>
52misc/arm contains a script for executing go binaries on android<br/>
53misc/cgo contains tests and examples of cgo<br/>
54misc/chrome contains a Chrome extension<br/>
55misc/git contains a pre-commit hook<br/>
56misc/ios contains information on cross compiling for iOS<br/>
57misc/linkcheck contains a program checking links on the godoc website<br/>
58misc/nacl contains Go's integration with nacl, used by the Go playground<br/>
59misc/sortac contains a utility for sorting the AUTHORS and CONTRIBUTORS files<br/>
60misc/swig contains examples of using Go with SWIG<br/>
61misc/trace contains a generated file used by go tool trace
jimmyfrasche4b647142017-10-05 16:12:10 -070062
forskningb96b2bf2019-03-24 14:20:15 -050063```
64% tree -d -L 1 $GOROOT/misc | head -n 12
65/usr/lib/go1.9.2/go/misc
66|-- android
67|-- arm
68|-- cgo
69|-- chrome
70|-- git
71|-- ios
72|-- linkcheck
73|-- nacl
74|-- sortac
75|-- swig
76`-- trace
77%
78```
jimmyfrasche4b647142017-10-05 16:12:10 -070079
forskningb96b2bf2019-03-24 14:20:15 -050080pkg contains libs, header files, compiled object files, and executables
jimmyfrasche4b647142017-10-05 16:12:10 -070081
forskningb96b2bf2019-03-24 14:20:15 -050082```
83% tree -d -L 1 $GOROOT/pkg | head -n 7
84/usr/lib/go1.9.2/go/pkg
85|-- bootstrap
86|-- include
87|-- linux_386
88|-- linux_386_dynlink
89|-- obj
90`-- tool
91%
92```
jimmyfrasche4b647142017-10-05 16:12:10 -070093
forskningb96b2bf2019-03-24 14:20:15 -050094test contains tests of the Go tool chain and runtime
jimmyfrasche4b647142017-10-05 16:12:10 -070095
forskningb96b2bf2019-03-24 14:20:15 -050096the github.com/golang net and tools sub-repositories and github.com/gonum/gonum repository can be located in /usr/share/gocode, utilising the following commands
jimmyfrasche1842d8e2017-10-05 16:18:43 -070097
forskningb96b2bf2019-03-24 14:20:15 -050098```
99% su -c tcsh
100Password:
101# setenv GOPATH /usr/share/gocode
102# go get -u golang.org/x/tools/...
103# go get -u gonum.org/v1/gonum/...
104# find $GOPATH -print0 | xargs -0 file | grep "executable" | grep ELF \
105? | cut -f 1 -d : | xargs strip --strip-unneeded
106# exit
107%
108```
jimmyfrasche1842d8e2017-10-05 16:18:43 -0700109
forskningb96b2bf2019-03-24 14:20:15 -0500110to compile Go code with the libraries in /usr/share/gocode you must add the location to $GOPATH
jimmyfrasche1842d8e2017-10-05 16:18:43 -0700111
forskningb96b2bf2019-03-24 14:20:15 -0500112```
113% setenv GOPATH $HOME/go:/usr/share/gocode
114% go get -u golang.org/x/blog
115package golang.org/x/blog: no Go files in /home/eric/go/src/golang.org/x/blog
116% cd go/src/golang.org/x/blog/blog
117% go build
118% mv blog $HOME/go/bin
119%
120```
jimmyfrascheef5e7ea2017-10-05 16:42:07 -0700121
forskningb96b2bf2019-03-24 14:20:15 -0500122this page utilises the C shell as [Setting GOPATH](https://github.com/golang/go/wiki/SettingGOPATH) doesn't include that shell
jimmyfrasche1842d8e2017-10-05 16:18:43 -0700123
forskningb96b2bf2019-03-24 14:20:15 -0500124for information on running the blog server see [Go Blog](https://github.com/golang/blog); those instructions might be more comprehensive being edited, but for Un*x just omit the .exe
125file extension