欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2021年11月16日 09:23:06   作者:秋天的春  
這篇文章主要為大家介紹了Golang開發(fā)Go依賴管理工具dep安裝驗證及初始化一系列實現(xiàn)過程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步

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
  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.tomlGopkg.lock文件

默認(rèn)初始化

$ dep init -v

直接從對應(yīng)網(wǎng)絡(luò)資源處下載

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

$ dep init -gopath -v

該命令會先從$GOPATH查找既有的依賴包,若不存在則從對應(yīng)網(wǎng)絡(luò)資源處下載

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生成,包含一個項目依賴關(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"

常用命令

dep ensure

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

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

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安裝驗證實現(xiàn)過程的詳細(xì)內(nèi)容,更多關(guān)于Golang開發(fā)Go依賴管理工具dep的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Go語言實現(xiàn)UDP協(xié)議及TCP通訊

    Go語言實現(xiàn)UDP協(xié)議及TCP通訊

    這篇文章介紹了Go語言實現(xiàn)UDP協(xié)議及TCP通訊的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-07-07
  • Go語言實現(xiàn)IP段范圍校驗示例

    Go語言實現(xiàn)IP段范圍校驗示例

    這篇文章主要介紹了Go語言實現(xiàn)IP段范圍校驗示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • Go語言中切片使用的注意事項小結(jié)

    Go語言中切片使用的注意事項小結(jié)

    切片是引用類型,相信對大家來說都不陌生,下面這篇文章主要給大家總結(jié)介紹了關(guān)于Go語言中切片使用的一些注意事項,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-01-01
  • 使用systemd部署和守護golang應(yīng)用程序的操作方法

    使用systemd部署和守護golang應(yīng)用程序的操作方法

    systemd是一個流行的守護進程管理器,可以輕松管理服務(wù)的啟動、停止、重啟等操作,讓我們的應(yīng)用程序始終保持在線,本文介紹了如何使用systemd部署和守護golang應(yīng)用程序,感興趣的朋友一起看看吧
    2023-10-10
  • Golang如何調(diào)用Python代碼詳解

    Golang如何調(diào)用Python代碼詳解

    這篇文章主要給大家介紹了關(guān)于Golang如何調(diào)用Python代碼的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-10-10
  • 使用Go語言簡單模擬Python的生成器

    使用Go語言簡單模擬Python的生成器

    這篇文章主要介紹了使用Go語言簡單模擬Python的生成器,Python的generator是非??岬墓δ?用Go實現(xiàn)的代碼也較為簡潔,需要的朋友可以參考下
    2015-08-08
  • Golang基于Vault實現(xiàn)敏感信息保護

    Golang基于Vault實現(xiàn)敏感信息保護

    Vault?是一個強大的敏感信息管理工具,自帶了多種認(rèn)證引擎和密碼引擎,本文主要探討應(yīng)用程序如何安全地從?Vault?獲取敏感信息,并進一步實現(xiàn)自動輪轉(zhuǎn),感興趣的可以了解一下
    2023-06-06
  • 淺談golang的json.Unmarshal的坑

    淺談golang的json.Unmarshal的坑

    本文主要介紹了淺談golang的json.Unmarshal的坑,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • Golang中如何使用lua進行擴展詳解

    Golang中如何使用lua進行擴展詳解

    這篇文章主要給大家介紹了關(guān)于Golang中如何使用lua進行擴展的相關(guān)資料,這是最近在工作中遇到的一個問題,覺著有必要分享出來給大家學(xué)習(xí),文中給出了詳細(xì)的示例,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-10-10
  • golang 獲取當(dāng)前執(zhí)行程序路徑的操作

    golang 獲取當(dāng)前執(zhí)行程序路徑的操作

    這篇文章主要介紹了golang 獲取當(dāng)前程序執(zhí)行路徑的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-12-12

最新評論