It's better than nothing: Go relies on Administrative tools DEP

Source: Internet
Author: User

Introduced

One problem that the early Golang were criticized by many developers was the management of the package. Golang 1.5 Release release, you can only solve this problem by setting up multiple Gopath, for example: both of my projects rely on Beego, but the a project relies on that Beego1.1 B project relies on Beego1.7 that I must set two gopath to differentiate , and when switching engineering, Gopath also have to switch, extremely painful. Finally finally in Golang 1.5 release began to support in addition to goroot and Gopath dependent query, that is vender , so many big guy started to build wheels, build better should be dep and glide .

Protagonist appearances

Today's protagonist is dep Golang's official Reliance Tool for managing and downloading engineering-dependent tools, the following is an official introduction

DEP is a prototype dependency management tool for Go. It requires Go 1.9 or newer to compile. DEP is safe for production use.

Installation

    • MacOSbrew install dep
    • Linuxcurl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
    • Windowsgo get -u github.com/golang/dep/cmd/dep
      Windows has to compile itself and make sure to $GOPATH/bin add it to the environment variable $PATH

Verify

Enter and return at the command line and the dep following prompt will appear, indicating that the installation was successful.

Image.png

function Introduction

    1. DEP Init


      Image.png

Back up the current vender , create a vender directory and download all the dependent packages in the project, build Gopkg.lock andGopkg.toml
The following is a description of the function of the two files, which is simply a Gopkg.toml manifest file, which Gopkg.lock is a checksum file. Try not to modify and avoid errors that cause two files to be unsynchronized.

A manifest-a file describing the current project ' s dependency requirements. In DEP, this is the gopkg.toml file. A lock-a file containing a transitively-complete, reproducible description of the dependency graph. In DEP, this is the Gopkg.lock file.

    1. DEP status
      Used to view the details and status of project dependencies, very clear.


      Image.png
    2. DEP ensure
      Try to make sure that all dependent libraries are installed, and if they are not downloaded, they are equivalent to incremental updates to the dependent libraries.

    3. DEP ensure add github.com/roaringbitmap/roaring@^1.0.1
      Download add a new dependent library, and incrementally update the manifest file and verify the description file. is a library- github.com/RoaringBitmap/roaring dependent package name, which 1.0.1 is the version number of the library.

Local cache

Of course, DEP does not download every time, it works like Mevan, it will take precedence in the local warehouse search, the local repository is not found on the network downloaded, and added to the local warehouse.
$GOPATH/pkg/dep/sources

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.