Update en/01.2.md - Fix typos
This commit is contained in:
10
en/01.2.md
10
en/01.2.md
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## $GOPATH
|
## $GOPATH
|
||||||
|
|
||||||
Go commands all rely on one important environment variable called $GOPATH. Notice that this is not the $GOROOT variable where Go is installed. This variable points to the workspace of Go on your computer (I use this path on my computer; if you don't have the same directory structure, please replace by yourself).
|
Go commands all rely on one important environment variable called $GOPATH. Notice that this is not the $GOROOT variable where Go is installed. This variable points to the workspace of Go on your computer (I use this path on my computer; if you don't have the same directory structure, please replace it by yourself).
|
||||||
|
|
||||||
In Unix-like systems, the variable should be used like this:
|
In Unix-like systems, the variable should be used like this:
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ In this book, I use `mygo` as my only path in $GOPATH.
|
|||||||
|
|
||||||
## Package directory
|
## Package directory
|
||||||
|
|
||||||
Create package source files and folders like `$GOPATH/src/mymath/sqrt.go` (`mymath` is the package name) ( ***Author uses `mymath` as his package name, and same name for the folder where contains package source files***)
|
Create package source files and folders like `$GOPATH/src/mymath/sqrt.go` (`mymath` is the package name) ( ***Author uses `mymath` as his package name, and the same name for the folder that contains the package source files***)
|
||||||
|
|
||||||
Every time you create a package, you should create a new folder in the `src` directory. Folder names are usually the same as the package that you are going to use. You can have multi-level directories if you want to. For example, if you create the directory `$GOPATH/src/github.com/astaxie/beedb`, then the package path would be `github.com/astaxie/beedb`. The package name will be the last directory in your path, which is `beedb` in this case.
|
Every time you create a package, you should create a new folder in the `src` directory. Folder names are usually the same as the package that you are going to use. You can have multi-level directories if you want to. For example, if you create the directory `$GOPATH/src/github.com/astaxie/beedb`, then the package path would be `github.com/astaxie/beedb`. The package name will be the last directory in your path, which is `beedb` in this case.
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ Execute following commands. ( ***Now author goes back to talk examples*** )
|
|||||||
cd $GOPATH/src
|
cd $GOPATH/src
|
||||||
mkdir mymath
|
mkdir mymath
|
||||||
|
|
||||||
Create a new file called `sqrt.go`, type following content to your file.
|
Create a new file called `sqrt.go`, type the following content to your file.
|
||||||
|
|
||||||
// Source code of $GOPATH/src/mymath/sqrt.go
|
// Source code of $GOPATH/src/mymath/sqrt.go
|
||||||
package mymath
|
package mymath
|
||||||
@@ -44,7 +44,7 @@ Create a new file called `sqrt.go`, type following content to your file.
|
|||||||
return z
|
return z
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
## Compile packages
|
## Compile packages
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ Create a new application package called `mathapp`.
|
|||||||
cd mathapp
|
cd mathapp
|
||||||
vim main.go
|
vim main.go
|
||||||
|
|
||||||
code
|
Write the following content to main.go.
|
||||||
|
|
||||||
//$GOPATH/src/mathapp/main.go source code.
|
//$GOPATH/src/mathapp/main.go source code.
|
||||||
package main
|
package main
|
||||||
|
|||||||
Reference in New Issue
Block a user