|
2 | 2 |
|
3 | 3 | ## $GOPATH
|
4 | 4 |
|
5 |
| -Go takes a unique approach to manage the code files with the introduction of a `$GOPATH` directory which contains all the go code in the machine. Note that this is different from the `$GOROOT` environment variable which states where go is installed on the machine. We have to define the `$GOPATH` variable before using the language, in *nix systems there is a file called `.profile` we need to append the below export statement to the file. The concept behind gopath is a novel one, where we can link to any go code at any instant of time without ambiguity. |
| 5 | +Go takes a unique approach to manage the code files with the introduction of a `$GOPATH` directory which contains all the go code on the machine. Note that this is different from the `$GOROOT` environment variable which states where go is installed on the machine. We have to define the `$GOPATH` variable before using the language, in *nix systems there is a file called `.profile` we need to append the below export statement to the file. The concept behind gopath is a novel one, where we can link to any go code at any instant of time without ambiguity. |
6 | 6 |
|
7 |
| -Starting from go 1.8, the GOPATH environment variable now has a default value if it is unset. It defaults to `$HOME/go` on Unix and `%USERPROFILE%/go` on Windows. |
| 7 | +Starting from go 1.8, the GOPATH environment variable now has a default value if it not set: it defaults to `$HOME/go` on Unix and `%USERPROFILE%/go` on Windows. |
8 | 8 |
|
9 |
| -In Unix-like systems, the variable should be used like this: |
| 9 | +On Unix-like systems, the variable should be used like this: |
10 | 10 |
|
11 | 11 | export GOPATH=${HOME}/mygo
|
12 | 12 |
|
13 | 13 | In Windows, you need to create a new environment variable called GOPATH, then set its value to `c:\mygo`( ***This value depends on where your workspace is located*** )
|
14 | 14 |
|
15 |
| -It's OK to have more than one path (workspace) in `$GOPATH`, but remember that you have to use `:`(`;` in Windows) to break them up. At this point, `go get` will save the content to your first path in `$GOPATH`. It is highly recommended to not have multiples versions, the worst case is to create a folder by the name of your project right inside `$GOPATH`, it breaks everything that the creators were wishing to change in programming with the creation of go language because when you create a folder inside `$GOPATH` you will reference your packages as directly as <packagename>, and this breaks all the applications which will import your package because the `go get` won't find your package. Please follow conventions, there is a reason conventions are created. |
| 15 | +It's OK to have more than one path (workspace) in `$GOPATH`, but remember that you have to use `:`(`;` in Windows) to separate them. At this point, `go get` will save the content to your first path in `$GOPATH`. It is highly recommended to not have multiples versions, the worst case is to create a folder by the name of your project right inside `$GOPATH`, it breaks everything that the creators were wishing to change in programming with the creation of go language because when you create a folder inside `$GOPATH` you will reference your packages as directly as <packagename>, and this breaks all the applications which will import your package because the `go get` won't find your package. Please follow conventions, there is a reason conventions are created. |
16 | 16 |
|
17 | 17 | In `$GOPATH`, you must have three folders as follows:
|
18 | 18 |
|
@@ -46,7 +46,7 @@ func Sqrt(x float64) float64 {
|
46 | 46 | return z
|
47 | 47 | }
|
48 | 48 | ```
|
49 |
| -Now my package directory has been created and it's code has been written. I recommend that you use the same name for your packages as their corresponding directories, and that the directories contain all of the package source files. |
| 49 | +Now my package directory has been created and its code has been written. I recommend that you use the same name for your packages as their corresponding directories, and that the directories contain all of the package source files. |
50 | 50 |
|
51 | 51 | ## Compile packages
|
52 | 52 |
|
@@ -145,7 +145,7 @@ If you've followed all of the above steps, your directory structure should now l
|
145 | 145 | beedb.go
|
146 | 146 | util.go
|
147 | 147 |
|
148 |
| -Now you are able to see the directory structure clearly; `bin` contains executable files, `pkg` contains compiled files and `src` contains package source files. |
| 148 | +Now you are able to see the directory structure clearly: `bin` contains executable files, `pkg` contains compiled files and `src` contains package source files. |
149 | 149 |
|
150 | 150 | (The format of environment variables in Windows is `%GOPATH%`, however this book mainly follows the Unix-style, so Windows users need to replace these yourself.)
|
151 | 151 |
|
|
0 commit comments