Golang compilation

Olang compiles the command go build , go install ; unless you only write a main function, the directory structure is still prepared; GOPATH=project root directory; under it should create src, pkg, bin directory, bin directory for generating executable files, pkg directory for generating .a files; The import name in golang is actually going to GOPATH to find name.a, which is the package name of the life in the source of the name.a; this has already been introduced. be careful: 1. When the system compiles go install abc_name, the system will look for the abc_name directory in the src directory of the GOPATH, and then compile the go file under it; 2. The package declarations of all go files in the same directory must be the same, so the main method should put a separate file, otherwise it will report an error in eclipse and liteide; The compiler reports the following error: (assuming there is a main.go and mymath.go in the test directory, where main.go declares the package as main and mymath.go declares packag as test); $ go install test Can't load package: package test: found packages main (main.go) and test (mymath.go) in /home/wanjm/go/src/test I can't load the package test (this is the command line argument) because I found two packages, main.go and mymath.go respectively. 3. For the main method, you can only run go build path_tomain.go in the bin directory; you can use the -o parameter to indicate the output file name; 4. You can add the parameter go build -gcflags "-N -l" ****, which is better for gdb; see http://golang.org/doc/gdb for details. 5. The gdb global variable is the main point. If there is a global variable a; then it should be written as p 'main.a'; note that the quotes are essential; Go eclipse: Go main file is best placed in a directory, otherwise there is a compilation error;