This is a created article in which the information may have evolved or changed.
Golang package and Java as JS, such as the big difference, must exist Gopath inside, Gopath is dedicated to store Golang third-party library, there are two folders,
SRC: Source code Directory
Pkg: Compiled third-party package, which is generated when go install, can not be manually changed
The two folders have the same file structure, as follows:
We want to make our own code base, then we have to create a new package under SRC, the package name of the file should be consistent.
For example, I create a new folder called Hehe under src:
Then open in the editor, create a package called hehe, and write a random method:
If there is no problem after build, perform the install operation, then we can see the generated package under the Pkg folder.
Then we can use this package in other projects: