Use dep to configure the operation of the golang development environment
- 2020-06-07 04:39:48
golang's package management 1 has no official package management solution, resulting in a number of unofficial package management tools. The previous gb (https:// getgb.io /) I used was a good way to separate the various golang projects, as the ones created by gb did not fit into the existing GOPATH. gb refers to the project directory as GOPATH, and its vendor directory is not exactly the same as golang's own vendor.
dep's Roadmap has plans to become the official golang package management tool, so using dep to organize your own golang project will be more integrated with other golang projects.
My golang configuration is mainly divided into three parts:
The & # 8226; GOROOT: For golang itself, when updating the golang version, just update this
The & # 8226; GOPATH: Tools for storing golang (gofmt, gocode, etc.)
The & # 8226; GOPROJECTS: For various golang projects
Configuration of go project
Create your own golang project under $GOPROJECTS/src
cd $GOPROJECTS/src mkdir myGolangProject cd myGolangProject touch main.go # write some golang code in main.go dep init dep ensure # add dependencies for main.go go install # compile myGolangProject
myGolangProject can be submitted to a remote git repository as an git repository for easy sharing with others
In fact, many golang package management tools are good, even without package management tools, GOPATH can achieve the purpose of golang project management by rational division. One reason for using dep is that it is likely to become the official package management tool for golang in the future, and the other is to better share the golang code. After all, through dep, others can install all dependencies with one key, avoiding many installation instructions.