Update en/01.3.md - Fix typos
This commit is contained in:
12
en/01.3.md
12
en/01.3.md
@@ -2,7 +2,7 @@
|
||||
|
||||
## Go commands
|
||||
|
||||
The Go language comes with a complete set of command operation tools. You can execute the command line `go` to see them:
|
||||
The Go language comes with a complete set of command operation tools. You can execute the `go` command on the terminal to see them:
|
||||
|
||||

|
||||
|
||||
@@ -12,9 +12,9 @@ These are all useful for us. Let's see how to use some of them.
|
||||
|
||||
## go build
|
||||
|
||||
This command is for compiling tests. It will compile dependence packages if it's necessary.
|
||||
This command is for compiling tests. It will compile packages and dependencies if it's necessary.
|
||||
|
||||
- If the package is not the `main` package such as `mymath` in section 1.2, nothing will be generated after you execute `go build`. If you need package file `.a` in `$GOPATH/pkg`, use `go install` instead.
|
||||
- If the package is not the `main` package such as `mymath` in section 1.2, nothing will be generated after you execute `go build`. If you need the package file `.a` in `$GOPATH/pkg`, use `go install` instead.
|
||||
- If the package is the `main` package, it will generate an executable file in the same folder. If you want the file to be generated in `$GOPATH/bin`, use `go install` or `go build -o ${PATH_HERE}/a.exe.`
|
||||
- If there are many files in the folder, but you just want to compile one of them, you should append the file name after `go build`. For example, `go build a.go`. `go build` will compile all the files in the folder.
|
||||
- You can also assign the name of the file that will be generated. For instance, in the `mathapp` project (in section 1.2), using `go build -o astaxie.exe` will generate `astaxie.exe` instead of `mathapp.exe`. The default name is your folder name (non-main package) or the first source file name (main package).
|
||||
@@ -47,7 +47,7 @@ I usually use this command to clean up my files before I upload my project to Gi
|
||||
|
||||
## go fmt and gofmt
|
||||
|
||||
The people who are working with C/C++ should know that people are always arguing about which code style is better: K&R-style or ANSI-style. However in Go, there is only one code style which is enforced. For example, left braces must only be inserted at the end of lines, and they cannot be on their own lines, otherwise you will get compile errors! Fortunately, you don't have to remember these rules. `go fmt` does this job for you. Just execute the command `go fmt <File name>.go` in terminal. I don't use this command very much because IDEs usually execute this command automatically when you save source files. I will talk about IDEs more in the next section.
|
||||
The people who are working with C/C++ should know that people are always arguing about which code style is better: K&R-style or ANSI-style. However in Go, there is only one code style which is enforced. For example, left braces must only be inserted at the end of lines, and they cannot be on their own lines, otherwise you will get compile errors! Fortunately, you don't have to remember these rules. `go fmt` does this job for you. Just execute the command `go fmt <File name>.go` in terminal. I don't use this command very much because IDEs usually execute this command automatically when you save source files. I will talk more about IDEs in the next section.
|
||||
|
||||
`go fmt` is just an alias, which runs the command 'gofmt -l -w' on the packages named by the import paths.
|
||||
|
||||
@@ -62,7 +62,7 @@ This command is for getting remote packages. So far, it supports BitBucket, Gith
|
||||
Google Code (Git, Mercurial, Subversion)
|
||||
Launchpad (Bazaar)
|
||||
|
||||
In order to use this command, you have to install these tools correctly. Don't forget to set `$PATH`. By the way, it also supports customized domain names. Use `go help remote` for more details about this.
|
||||
In order to use this command, you have to install these tools correctly. Don't forget to update the `$PATH` variable. By the way, it also supports customized domain names. Use `go help remote` for more details about this.
|
||||
|
||||
## go install
|
||||
|
||||
@@ -92,7 +92,7 @@ Execute the `godoc -http=:8080` command, then open `127.0.0.1:8080` in your brow
|
||||
Go provides more commands than those we've just talked about.
|
||||
|
||||
go fix // upgrade code from an old version before go1 to a new version after go1
|
||||
go version // get information about your version of Go
|
||||
go version // get information about your version of Go
|
||||
go env // view environment variables about Go
|
||||
go list // list all installed packages
|
||||
go run // compile temporary files and run the application
|
||||
|
||||
Reference in New Issue
Block a user