If you want to start learning go grammar, please memorize the following 4 points:
1. Environment variables:
Use Go env to view environment variables
Goarch/gohostarch: Architecture, AMD64 or 386
Goos/gohostos: Operating system, Linux or Windows
Goroot:go installation directory
Gobin:go Program Directory
Gotooldir:go Tools Directory
Cgo_enabled: Enable CGO
Cc
CXX
Gogccflags
Gorace: Data sync detection, with go to test, go run, go builds, go install-race options.
Gopath:go Package Lookup Path
2. Code organization:
-$GOPATH contains multiple workspace
-Workspace contains src, pkg, bin
-SRC contains package, program, library
-Package contains go file
Need to understand:
* Package name vs Package path
Package name refers to the Identifie that uses the package declaration in go file. Package path refers to the relative gopath paths. Same package path, same package name.
Package Import Complete Syntax:
Import [Name] "path"
which
The name section can
No, default name with package declaration
Point, using the current package
Blank, execute init only
Name, custom names
The path section can
Absolute path: A relative $gopath path
Relative path: The path relative to the current file.
Note: You cannot use the vendor mechanism to show a relative path, otherwise parsing is an error .
* Program vs Library
Package name is main representing program
Package name not main represents library
3. Code Testing
Use the Go Test command to execute the test code.
Test file has a suffix of _test.
Test func is prefixed with test.
4. Remote Package
Obtain a remote package using the go to command.
But the Go Test command relies on git or svn.