Code md consistency 01.2
This commit is contained in:
12
en/01.2.md
12
en/01.2.md
@@ -2,9 +2,9 @@
|
||||
|
||||
## $GOPATH
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
In Unix-like systems, the variable should be used like this:
|
||||
|
||||
@@ -12,15 +12,15 @@ In Unix-like systems, the variable should be used like this:
|
||||
|
||||
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*** )
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
In $GOPATH, you must have three folders as follows:
|
||||
In `$GOPATH`, you must have three folders as follows:
|
||||
|
||||
- `src` for source files whose suffix is .go, .c, .g, .s.
|
||||
- `pkg` for compiled files whose suffix is .a.
|
||||
- `bin` for executable files
|
||||
|
||||
In this book, I use `mygo` as my only path in $GOPATH.
|
||||
In this book, I use `mygo` as my only path in `$GOPATH`.
|
||||
|
||||
## Package directory
|
||||
|
||||
@@ -116,7 +116,7 @@ After executing the above commands, the directory structure should look like fol
|
||||
|-astaxie
|
||||
|-beedb.a
|
||||
|
||||
Actually, `go get` clones source code to the $GOPATH/src of the local file system, then executes `go install`.
|
||||
Actually, `go get` clones source code to the `$GOPATH/src` of the local file system, then executes `go install`.
|
||||
|
||||
You can use remote packages in the same way that we use local packages.
|
||||
```Go
|
||||
|
||||
Reference in New Issue
Block a user