GO Dependent Management Tool – Dep

http://www.voidcn.com/article/p-owmhewvt-bse.html

Go dependency management tool

Go dependency management tool

Environmental requirements

  • Golang >= 1.9
  • Dep

Current version:

dep: version: devel build date: git hash: go version: go1.10 go compiler: gc platform: linux/amd64 

Latest release is v0.4.1

Installation

h2>

go get -u github.com/golang/dep/cmd/dep 

If $GOPATH/bin is not under PATH, you need to remove the generated dep file from < code>$GOPATH/bin move to $GOBIAN down

Verification

$ dep
Dep is a tool for managing dependencies for Go projects

Usage: "dep [command]"

Commands:

  init Set up a new Go project, or migrate an existing one status Report the status of the < span class="hljs-keyword">project's dependencies ensure Ensure a dependency is safely vendored in the project prune Pruning is now performed automatically by dep ensure. version Show the dep version information Examples : dep init set up a new project dep ensure install the project's dependencies dep ensure -update update the locked versions of all dependencies dep ensure -add github.com/pkg/errors add a dependency to the project Use "dep help [command]"  for more information about a command. < /pre> 

Initialization

Execute the initialization command in the project root directory, dep will analyze all the dependent packages required by the application during initialization, and get Export the dependency package list

and generate the vendor directory, Gopkg.toml, Gopkg.lock file

< p>imagedefault initialization
$ Dep init -v

Download directly from the corresponding network resource

Initialize from $GOPATH first

$dep init -gopath -v 

This command will first find the existing dependency package from $GOPATH, and download it from the corresponding network resource if it does not exist

Gopkg.toml

This file is generated by dep init and contains the rules and declarations governing the behavior of dep

required = ["github.com/user/thing/cmd/thing"] ignored = ["github.com/ user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] [metadata] key1 = "value that convey data to other systems" system1-data = "value that is used by a system" system2-data = "value that is used by another system "[[constraint]] # Required: the root import path of the project being constrained. name = "github.com/user/project" # Recommended: the version constraint to enforce for the project. # Note that only one of "branch", "version" or "revision" ca n be specified. version = "1.0.0" branch = "master" revision = "abc123 "# Optional: an alternate location (URL or import path) for the project's source. source = "https://github.com /myfork/package.git" # Optional: metadata about the constraint or override that could be used by other independent systems [metadata] key1 = " value that convey data to other systems" system1-data = "value that is used by a system" system2-data = "value that is used by another system" span>

Gopkg.lock

< p>This file is generated by dep ensure and dep init, and contains a complete snapshot of the delivery of the project dependency graph, expressed as a series of [[project]]< /code>Section

# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. [[projects]] branch = "master" name = "github.com/golang/protobuf" packages = ["jsonpb", "proto" , "protoc-gen-go/descriptor", "ptypes", "ptypes/any" , "ptypes/duration", "ptypes/struct", "ptypes/timestamp"] revision = "bbd03ef6da3a115852eaf24c8a1c46aeb39aa175" 

Common commands

dep ensure

From the project Gopkg. Analyze the relationship diagram in toml and Gopkg.lock, and obtain the required dependent packages

Used to ensure that the local relationship diagram, lock, and dependent package lists are completely consistent

dep ensure -add

# Introduce the latest version of the dependency package dep ensure -add github.com/pkg/foo # Introduce dependency package dep with specific constraints (specified version) ensure -add github.com/pkg/[email protected]^1.0.1 

dep ensure -update

Rely on the convention in Gopkg.lock The item is updated to the latest version allowed by Gopkg.toml

Finally

Currently, dep is still in official testing Stage, but it has been indicated that production is safe to use

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2292 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.