This is a creation in Article, where the information may have evolved or changed.
1. Establishment of the project
1---setting $gopath environment variables
For example, add the following statement to the ~/.BASHRC export $GOPAHT =/home/jj/goproj
(Don't forget the source ~/.BASHRC)
2--set up the engineering catalogue
Cd/home/jj
mkdir goproj
CD Goproj
mkdir src (this folder must be named SRC)
Mkdr Bin (this folder can be arbitrarily named)
3--adding source files in src directory
CD./src
Vim main. Go (main name is not required, can be any name)
MkDir Lib
CD./lib
Vim Lib1.go (edit a library for Main.go call, can be multiple, and the name is arbitrary)
2. Compiling the project
CD $GOPATH/bin
Go build main (must be with the file in src directory always, because go will search under $GOPATH/SRCZ, its dependent libraries do not have to be compiled separately, go will automatically deduce)
The main program is generated in the Bin directory when the compilation is complete.
3. Complete Engineering directory Structure
<goproj>
|--------<src>
| |-------main.go
| |-------<lib>
| |-------lib1.go
|---------<bin>