Golang is compiled using the command go build, go install, or the directory structure is ready unless you write only a main function,
gopath= the project root directory, under which the Src,pkg,bin directory should be created, which is used to build the executable file in the bin directory , the PKG directory is used to generate. A files,
Golang in the import name, is actually to Gopath to find Name.a, when used is the name.a of the source of life of the package name; This has been described in the previous.
Note:
1. When the system compiles go install Abc_name, the system will go to Gopath's src directory to find the Abc_name directory, and then compile the go file under it;
2. The package declaration must be the same for all go files in the same directory, so the main method is to put a separate file, otherwise it will be an error in Eclipse and liteide;
The compilation error is as follows: (suppose there is a main.go and mymath.go in the test directory, where Main.go declares that the package is Main,mymath.go declaration packag is 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
error saying the package could not be loaded Test (This is the command-line parameter) because two package was found, respectively Main.go and mymath.go;
3. For the main method, you can only run go build path_tomain.go in the bin directory; the output file name is indicated by the-o parameter;
4. You can add the parameter go build-gcflags "-n-l" * * *, can be more good for gdb; see Http://golang.org/doc/gdb
5. GDB global variable Master point. If there is a global variable A; it should be written as P ' main.a '; note but the quotation marks are not small;
Go compilation issues