您好,登錄后才能下訂單哦!
這篇文章主要講解了“Golang開發(fā)Go依賴管理工具dep安裝驗證實現(xiàn)過程是什么”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Golang開發(fā)Go依賴管理工具dep安裝驗證實現(xiàn)過程是什么”吧!
Go dependency management tool
Golang >= 1.9Dep
dep: version : devel build date : git hash : go version : go1.10 go compiler : gc platform : linux/amd64
Latest release
為v0.4.1
go get -u github.com/golang/dep/cmd/dep
若$GOPATH/bin
不在PATH
下,則需要將生成的dep
文件從$GOPATH/bin
移動至$GOBIAN
下
$ 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 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.
在項目根目錄執(zhí)行初始化命令,dep
在初始化時會分析應(yīng)用程序所需要的所有依賴包,得出依賴包清單
并生成vendor
目錄,Gopkg.toml
、Gopkg.lock
文件
$ dep init -v
直接從對應(yīng)網(wǎng)絡(luò)資源處下載
$ dep init -gopath -v
該命令會先從$GOPATH
查找既有的依賴包,若不存在則從對應(yīng)網(wǎng)絡(luò)資源處下載
該文件由dep init
生成,包含管理dep
行為的規(guī)則聲明
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"
該文件由dep ensure
和dep init
生成,包含一個項目依賴關(guān)系圖的傳遞完整快照,表示為一系列[[project]]
節(jié)
# 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"
從項目中的Gopkg.toml
和Gopkg.lock
中分析關(guān)系圖,并獲取所需的依賴包
用于確保本地的關(guān)系圖、鎖、依賴包清單完全一致
# 引入該依賴包的最新版本 dep ensure -add github.com/pkg/foo # 引入具有特定約束(指定版本)的依賴包 dep ensure -add github.com/pkg/foo@^1.0.1
將Gopkg.lock
中的約定依賴項更新為Gopkg.toml
允許的最新版本
感謝各位的閱讀,以上就是“Golang開發(fā)Go依賴管理工具dep安裝驗證實現(xiàn)過程是什么”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Golang開發(fā)Go依賴管理工具dep安裝驗證實現(xiàn)過程是什么這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。