This is a creation in Article, where the information may have evolved or changed.
Read the "Go" note https://github.com/Unknwon/the-way-to-go_ZH_CN
The second chapter is about the go installation and operating environment, I have written before Linux go installed, Windows and Mac installation is not written down, its environment variable meaning is worth noting
$GOROOT indicates where Go is installed on your PC, and it's usually the $HOME/go
same value, and you can install it somewhere else, of course.
$GOARCH represents the processor architecture of the target machine, and its value can be 386,amd64 or arm.
$GOOS represents the operating system of the target machine, and its value can be darwin,freebsd,linux or windows
$GOBIN indicates where the compiler and linker are installed, by default $GOROOT/bin
, if you are using Go 1.0.3 and later versions, you can normally set its value to NULL, and Go will use the default values mentioned earlier.
Go installation directory and its role can be understood (the following is the directory under window):
\ bin contains executable files, such as: Compiler, Go tool
\doc
Contains sample programs, code tools, local documents, etc.
\include
Contains a/C + + header file
\lib
Include document templates
\misc
Contains examples of configuration files and cgo that support the Go editor
\pkg\os_arch
The object file () of the package that contains the standard library .a
\src
Include source code build script
\src\cmd
Compiler and command line scripts with Go and C
\src\lib9
\src\libbio
\src\libmach
contains C files
src\pkg
Full source code for packages containing Go standard library (go is an open source language)
The third chapter is about the editor and integrated development tools and other tools, I think liteide is very useful, but take a good look at this chapter is also a harvest
Like what:
fmt.Printf
use the following specifier in to print information about the variable:
%+v
Print full information about an instance that includes a field
%#v
Print full information for instances that include fields and qualified type names
%T
Print a full description of a type
GOFMT and Godoc applications, very powerful tools
Some examples of commands:
Gofmt–w format and rewrite the file, you can specify a file, *.go you can rewrite a lot of files at once, you can also specify a directory, format all the go files in that directory
Gofmt-r "(a)-a" –w *.go before formatting can be replaced by noon replace "original content, replace content"
The Go Doc package gets the documentation comments for the packages, for example: go doc fmt
godoc
A document comment that uses the generated package is displayed fmt
.
go doc package/subpackage
Gets the document comment for the child package, for example: go doc container/list
.
go doc package function
Gets the document comment for a function in a package, for example: go doc fmt Printf
displays fmt.Printf()
instructions for use.
The godoc-http=:6060 command, which provides a page that the browsing server can access on port 6060,
Go to C and C + + calls, to tell the truth, temporarily did not see, want to use the time, self-write some code, use will deepen the impression it