This is a created article in which the information may have evolved or changed.
Go is a programming language that advocates software engineering concepts.
The go code must be placed in the workspace. A workspace is actually a directory that corresponds to a specific project, and it should contain three subdirectories:
SRC is used to organize and save go source files in the form of a code package. Should be divided into three categories: library source code files, command source files, test source files.
Pkg is used to store the ". A" archive of the installed code package (library source file) built by the Go Install command. Like the pkg feature in the Goroot directory, the difference is that the PKG directory in the working directory is designed to hold the archive file for user code.
When the bin is installed through the Go Install command, the executable file generated by the Go command source file is saved.
PS: The so-called command source files, which can be run independently, can be converted into executable files by Go build or go Install command. Library source file refers to a code package of common source files.
Set Gopath
$vim/etc/profile
Export gopath= $HOME/golang/lib: $HOME/golang/learngo
$source/etc/profile
$HOME/golang/lib for storing third-party code libraries (go get command)
$HOME/golang/learngo to store learning code