Configuring the Golang development environment with DEP

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.