forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 1 | This 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. |
jimmyfrasche | d3f1281 | 2017-10-05 15:36:01 -0700 | [diff] [blame] | 2 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 3 | ``` |
| 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 | ``` |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 17 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 18 | api contains data for Go's API checker |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 19 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 20 | ``` |
| 21 | % ls $GOROOT/api |
| 22 | README go1.1.txt go1.3.txt go1.5.txt go1.7.txt go1.9.txt next.txt |
| 23 | except.txt go1.2.txt go1.4.txt go1.6.txt go1.8.txt go1.txt |
| 24 | % |
| 25 | ``` |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 26 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 27 | bin contains the go and gofmt executables |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 28 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 29 | ``` |
| 30 | % ls -l $GOROOT/bin |
| 31 | total 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 | ``` |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 36 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 37 | doc contains .css, .go, .html, .js, and .png files |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 38 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 39 | lib contains the compressed time zone database |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 40 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 41 | ``` |
| 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 | ``` |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 50 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 51 | misc/android contains information on development for android<br/> |
| 52 | misc/arm contains a script for executing go binaries on android<br/> |
| 53 | misc/cgo contains tests and examples of cgo<br/> |
| 54 | misc/chrome contains a Chrome extension<br/> |
| 55 | misc/git contains a pre-commit hook<br/> |
| 56 | misc/ios contains information on cross compiling for iOS<br/> |
| 57 | misc/linkcheck contains a program checking links on the godoc website<br/> |
| 58 | misc/nacl contains Go's integration with nacl, used by the Go playground<br/> |
| 59 | misc/sortac contains a utility for sorting the AUTHORS and CONTRIBUTORS files<br/> |
| 60 | misc/swig contains examples of using Go with SWIG<br/> |
| 61 | misc/trace contains a generated file used by go tool trace |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 62 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 63 | ``` |
| 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 | ``` |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 79 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 80 | pkg contains libs, header files, compiled object files, and executables |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 81 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 82 | ``` |
| 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 | ``` |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 93 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 94 | test contains tests of the Go tool chain and runtime |
jimmyfrasche | 4b64714 | 2017-10-05 16:12:10 -0700 | [diff] [blame] | 95 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 96 | the 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 |
jimmyfrasche | 1842d8e | 2017-10-05 16:18:43 -0700 | [diff] [blame] | 97 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 98 | ``` |
| 99 | % su -c tcsh |
| 100 | Password: |
| 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 | ``` |
jimmyfrasche | 1842d8e | 2017-10-05 16:18:43 -0700 | [diff] [blame] | 109 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 110 | to compile Go code with the libraries in /usr/share/gocode you must add the location to $GOPATH |
jimmyfrasche | 1842d8e | 2017-10-05 16:18:43 -0700 | [diff] [blame] | 111 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 112 | ``` |
| 113 | % setenv GOPATH $HOME/go:/usr/share/gocode |
| 114 | % go get -u golang.org/x/blog |
| 115 | package 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 | ``` |
jimmyfrasche | ef5e7ea | 2017-10-05 16:42:07 -0700 | [diff] [blame] | 121 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 122 | this page utilises the C shell as [Setting GOPATH](https://github.com/golang/go/wiki/SettingGOPATH) doesn't include that shell |
jimmyfrasche | 1842d8e | 2017-10-05 16:18:43 -0700 | [diff] [blame] | 123 | |
forskning | b96b2bf | 2019-03-24 14:20:15 -0500 | [diff] [blame] | 124 | for 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 |
| 125 | file extension |