|--bin|--pkg|--src
Where the bin holds the compiled executable file, the PKG holds the compiled package file, and SRC holds the project source file. Generally, the bin and pkg directories can be created without the GO command being created automatically (like go install), just create the SRC directory.
For the PKG directory, the files in the pkg are generated by go compilation, rather than manually put in. (General file suffix. a)
For the SRC directory, the source files are stored in the go, and the source files are organized in the form of packages. In general, creating a new package creates a new folder in the SRC directory.
test|--install '--src |--config | '--config.go '--Test '--main.go
Note that the package name in Config.go must be the best match for the directory config, and the file name can be random. Main.go represents the main package, and the file name is suggested as Main.go.
(Note: when inconsistent, the resulting. A file name and directory name are the same, so that when you import, it should be the directory name, and the package name is required when the package is referenced.) For example, if the directory is myconfig and the package name is config, then the production static package file is: MYCONFIG.A, referencing the package: import "Myconfig", using the package Member: CONFIG. Loadconfig ())
The code for CONFIG.GO and Main.go is as follows:
Config.go Code
Package Configfunc Loadconfig () {}
Main.go Code
Package Mainimport ("config" "FMT") func main () {config. Loadconfig () fmt. Println ("Hello, go!")}
Next, execute the./install in the project root directory.
The directory structure at this time is:
test|--bin| '--test|--install|--pkg| '--linux_amd64| '--config.a '--src |--config | '--config.go '--Test '--main.go (linux_amd64 means I use the operating system and architecture, you may not be the same)
Where CONFIG.A is generated after the package config is compiled; bin/test is a binary file that is generated
This time can be carried out: Bin/test. Will output: Hello, go!
Go project directory