This is a creation in Article, where the information may have evolved or changed.
Profile
Golang's package management has been without an official unified solution, and therefore has produced many unofficial package management tools. The GB (https://getgb.io/) I used to be able to separate the various Golang projects well, when the GB-created project was not very integrated into the existing gopath. GB is equivalent to the catalog of the project as Gopath, and its vendor directory is not the same as Golang own vendor.
DEP has already developed a plan to become the official package management tool for Golang, so using DEP to organize your own Golang projects can be better combined with other Golang projects later in the roadmap.
Configuration
Configuration of the Golang
The configuration of my golang is mainly divided into 3 blocks:
- Goroot: For storing the Golang itself, update the Golang version, just update this on the line
- Gopath: Tools for storing Golang (Gofmt,gocode, etc.)
Goprojects: For storing various golang projects
Export Goroot=/usr/local/go
Export Goprojects=/path/to/goprojects
Export Gopath=/path/to/gopath
Export path= $PATH: $GOROOT/bin: $GOPATH/bin: $GOPROJECTS/bin
Export gopath= $GOPATH: $GOPROJECTS
Configuration of Go Project
Create your own Golang project under the $GOPROJECTS/SRC
cd$GOPROJECTS/srcmkdir myGolangProjectcd myGolangProjecttouch main.go# write some golang code in main.godep initdep ensure # add dependencies for main.gogo install # compile myGolangProject
Mygolangproject can be submitted to a remote Git repository as a git repository for easy sharing with others
Summarize
In fact, a lot of Golang package management tools are good, even without package management tools, through a reasonable division Gopath can also achieve the purpose of Golang project management. Using DEP, on the one hand, is because it is likely to become Golang's official package management tool, but also to better share the Golang code, after all, through DEP, others can install all dependencies, avoid writing many of the installation instructions of the document.