Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the implementation process of Golang development Go dependency management tool dep installation verification

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "Golang development Go dependency management tool dep installation verification process is what", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Golang development Go dependency management tool dep installation verification process is what" it!

Go depends on the management tool Go dependency management tool environment requirements

Golang > = 1.9Dep

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

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

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

Verify $depDep is a tool for managing dependencies for Go projectsUsage: "dep [command]" Commands: init Set up a new Go project, or migrate an existing one status Report the status of the 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 informationExamples: 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. Initialization

Execute the initialization command in the project root directory, and dep will analyze all the dependency packages needed by the application during initialization to get the dependency package manifest

And generate vendor directory, Gopkg.toml, Gopkg.lock files

Initialize $dep init-v by default

Download directly from the corresponding network resources

Initialize $dep init-gopath-v from $GOPATH first

This command will first find the existing dependent 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 rule declarations that manage dep behavior

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" can 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" Gopkg.lock

This file is generated by dep ensure and dep init and contains a complete snapshot of the project dependency diagram delivered as a series of [[project]] sections

# 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 command dep ensure

Analyze the diagram from the Gopkg.toml and Gopkg.lock in the project and get the required dependency packages

Used to ensure that local diagrams, locks, and dependent package lists are completely consistent

Dep ensure-add# introduces the latest version of the dependency package dep ensure-add github.com/pkg/foo # introduces the dependency package dep ensure-add github.com/pkg/foo@ ^ 1.0.1 dep ensure-update with specific constraints (specified version)

Update the convention dependencies in Gopkg.lock to the latest version allowed by Gopkg.toml

Thank you for your reading, the above is the "Golang development Go dependency management tool dep installation verification process is what" the content, after the study of this article, I believe you on the Golang development Go dependency management tool dep installation verification process is what this problem has a deeper understanding, the specific use of the need for you to practice verification. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report