人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動態(tài)

Golang開發(fā)Go依賴管理工具dep安裝驗證實現過程

發(fā)布日期:2022-02-01 15:35 | 文章來源:gibhub

Go依賴管理工具

Go dependency management tool

環(huán)境要求

Golang >= 1.9Dep

目前版本

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

Latest releasev0.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
  statusReport the status of the project's dependencies
  ensureEnsure 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 initset up a new project
  dep ensure install the project's dependencies
  dep ensure -updateupdate 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在初始化時會分析應用程序所需要的所有依賴包,得出依賴包清單

并生成vendor目錄,Gopkg.toml、Gopkg.lock文件

默認初始化

$ dep init -v

直接從對應網絡資源處下載

優(yōu)先從$GOPATH初始化

$ dep init -gopath -v

該命令會先從$GOPATH查找既有的依賴包,若不存在則從對應網絡資源處下載

Gopkg.toml

該文件由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"

Gopkg.lock

該文件由dep ensuredep init生成,包含一個項目依賴關系圖的傳遞完整快照,表示為一系列[[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"

常用命令

dep ensure

從項目中的Gopkg.tomlGopkg.lock中分析關系圖,并獲取所需的依賴包

用于確保本地的關系圖、鎖、依賴包清單完全一致

dep ensure -add

# 引入該依賴包的最新版本
dep ensure -add github.com/pkg/foo
 
# 引入具有特定約束(指定版本)的依賴包
dep ensure -add github.com/pkg/foo@^1.0.1

dep ensure -update

Gopkg.lock中的約定依賴項更新為Gopkg.toml允許的最新版本

以上就是Golang開發(fā)Go依賴管理工具dep安裝驗證實現過程的詳細內容,更多關于Golang開發(fā)Go依賴管理工具dep的資料請關注本站其它相關文章!

海外穩(wěn)定服務器

版權聲明:本站文章來源標注為YINGSOO的內容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內容來源于網友推薦、互聯網收集整理而來,僅供學習參考,不代表本站立場,如有內容涉嫌侵權,請聯系alex-e#qq.com處理。

相關文章

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務

7x24全年不間斷在線

專屬顧問服務

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務熱線

關注
微信

關注官方微信
頂部