Golang包管理工具之govendor的使用
1. govendor簡介
golang工程的依賴包經常使用go get命令來獲取,例如:go get github.com/kardianos/govendor ,會將依賴包下載到GOPATH
的路徑下。
常用的依賴包管理工具有godep
,govendor
等,在Golang1.5之後,Go提供了 GO15VENDOREXPERIMENT
環境變數(Go 1.6版本預設開啟該環境變數),用於將go build時的應用路徑搜尋調整成為 當前專案目錄/vendor
目錄方式。通過這種形式,我們可以實現類似於 godep
方式的專案依賴管理。
2. 安裝與使用
2.1. 安裝
go get -u -v github. com/kardianos/govendor
2.2. 使用
#進入到專案目錄
cd /home/gopath/src/mytool
#初始化vendor目錄
govendor init
#檢視vendor目錄
[[email protected] mytool]# ls
commands main.go vendor mytool_test.sh
#將GOPATH中本工程使用到的依賴包自動移動到vendor目錄中
#說明:如果本地GOPATH沒有依賴包,先go get相應的依賴包
govendor add +external
或使用縮寫: govendor add +e
#Go 1.6以上版本預設開啟 GO15VENDOREXPERIMENT 環境變數,可忽略該步驟。
#通過設定環境變數 GO15VENDOREXPERIMENT=1 使用vendor資料夾構建檔案。
#可以選擇 export GO15VENDOREXPERIMENT=1 或 GO15VENDOREXPERIMENT=1 go build 執行編譯
export GO15VENDOREXPERIMENT=1
2.3. 說明
govendor
只是用來管理專案的依賴包,如果GOPATH
中本身沒有專案的依賴包,則需要通過go get
先下載到GOPATH中,再通過govendor add +external
拷貝到vendor
目錄中。Go 1.6以上版本預設開啟GO15VENDOREXPERIMENT環境變數
3. govendor使用命令
[[email protected] mytool]# govendor
govendor (v1.0.8): record dependencies and copy into vendor folder
-govendor-licenses Show govendor's licenses.
-version Show govendor version
-cpuprofile 'file' Writes a CPU profile to 'file' for debugging.
-memprofile 'file' Writes a heap profile to 'file' for debugging.
Sub-Commands
init Create the "vendor" folder and the "vendor.json" file.
list List and filter existing dependencies and packages.
add Add packages from $GOPATH.
update Update packages from $GOPATH.
remove Remove packages from the vendor folder.
status Lists any packages missing, out-of-date, or modified locally.
fetch Add new or update vendor folder packages from remote repository.
sync Pull packages into vendor folder from remote repository with revisions
from vendor.json file.
migrate Move packages from a legacy tool to the vendor folder with metadata.
get Like "go get" but copies dependencies into a "vendor" folder.
license List discovered licenses for the given status or import paths.
shell Run a "shell" to make multiple sub-commands more efficient for large
projects.
go tool commands that are wrapped:
"+status" package selection may be used with them
fmt, build, install, clean, test, vet, generate, tool
Status Types
+local (l) packages in your project
+external (e) referenced packages in GOPATH but not in current project
+vendor (v) packages in the vendor folder
+std (s) packages in the standard library
+excluded (x) external packages explicitly excluded from vendoring
+unused (u) packages in the vendor folder, but unused
+missing (m) referenced packages but not found
+program (p) package is a main package
+outside +external +missing
+all +all packages
Status can be referenced by their initial letters.
Package specifier
<path>[::<origin>][{/...|/^}][@[<version-spec>]]
Ignoring files with build tags, or excluding packages from being vendored:
The "vendor.json" file contains a string field named "ignore".
It may contain a space separated list of build tags to ignore when
listing and copying files.
This list may also contain package prefixes (containing a "/", possibly
as last character) to exclude when copying files in the vendor folder.
If "foo/" appears in this field, then package "foo" and all its sub-packages
("foo/bar", …) will be excluded (but package "bar/foo" will not).
By default the init command adds the "test" tag to the ignore list.
If using go1.5, ensure GO15VENDOREXPERIMENT=1 is set.
4. vendor.json
govendor配置檔案,記錄依賴包列表。
{
"comment": "",
"ignore": "test",
"package": [
{
"checksumSHA1": "uGalSICR4r7354vvKuNnh7Y/R/4=",
"path": "github.com/urfave/cli",
"revision": "b99aa811b4c1dd84cc6bccb8499c82c72098085a",
"revisionTime": "2017-08-04T09:34:15Z"
}
],
"rootPath": "mytool"
}
相關推薦
Golang包管理工具之govendor的使用
1. govendor簡介golang工程的依賴包經常使用go get命令來獲取,例如:go get github.com/kardianos/govendor ,會將依賴包下載到GOPATH的路徑下。常用的依賴包管理工具有godep,govendor等,在Golang1.5
Golang包管理工具(二)之glide的使用
1. glide簡介 glide是一個golang專案的包管理工具,非常方便快捷,一般只需要2-3個命令就可以將go依賴包自動下載並歸檔到vendor的目錄中。glide官網參考:https://
Linux 包管理工具之RPM詳解
linux rpm講到包管理工具,先來了解下應用程序接口 (API)與應用程序二進制接口 (ABI)。 API: 編程接口 Application Program Interface 換句話說也就是你編寫“應用程序”時候調用的函數之類的東西。對於內核來說,它的“應用程序”有兩種:一種是在它之上的,用戶空
Linux 包管理工具之Yum
linux yumYum(全稱為 Yellow dog Updater, Modified)是基於RPM包的包管理工具,能夠從指定的服務器自動下載RPM包並且安裝,可以自動處理依賴性關系,並且一次安裝所有依賴的軟件包,無須繁瑣地一次次下載、安裝。至於RPM的介紹,請參考 http://blog.51cto.c
golang包管理工具dep使用簡明攻略
安裝 dep需要golang版本在1.9以上go get -u github.com/golang/dep/cmd/dep dep工作流 因為有牆,所以使用之前請先設定命令列代理,梯子自備 export {http,https}_proxy='127.0.0.1:1
golang包管理解決之道——go modules初探
golang的包管理是一直是為人詬病之處,從golang1.5引入的vendor機制,到準官方工具dep,目前為止還沒一個簡便的解決方案。 不過現在go modules隨著golang1.11的釋出而和我們見面了,這是官方提倡的新的包管理,乃至專案管理機制,可以不再需要GO
Golang包管理工具Glide,你值得擁有
“依賴地獄”是每個程式設計師在成長之路上都會面臨的情況,首先我們通過語義化版本來控制軟體的版本,然後在我們的專案裡通過指定軟體版本來達到控制依賴的目的。 如:你的專案A依賴多個專案B1,B2,B3,而B1,B2,B3又依賴著其它專案C1,C2…。一個專案依賴這
golang包管理工具 glide 使用教程
Glide 是 Golang 的 Vendor 包管理器,方便你管理 vendor 和 verdor 包。類似 Java 的 Maven,PHP 的 Composer. 主要特性: 簡單管理依賴 支援 versioning packages,包括 Sema
包管理工具之Pipenv
屬性 cif pda tom 工具 all click markers lean pipenv 都包含什麽? pipenv 是 Pipfile 主要倡導者、requests 作者 Kenneth Reitz 寫的一個命令行工具,主要包含了Pipfile、pip、clic
Golang學習筆記之依賴包管理工具gvt
一、gvt概念 gvt全稱為Go vendoring tool,可譯為Go供應工具,或者意譯為Go依賴包依賴包工具,whatever~~,簡單來說就是可以方便的獲取、更新、刪除專案所依賴的工具包,這個特性在Go1.5之前並不支援,1.5版本中需要設定GO15VENDOREX
[golang] Glide 包管理工具,在windows10 64位系統上的bug修復方案
環境 all 管理工具 oos for 討論 pos inb direct bug重現 [ERROR] Unable to export dependencies to vendor directory: Error moving files: exit status 1
Glide--------Golang依賴包解決工具之錯誤實踐
docs gil ucc manage ear width end mat org 1. 背景 不論是開發Java還是你正在學習的Golang,都會遇到依賴管理問題。Java有牛逼轟轟的Maven和Gradle。 Golang亦有godep、govendor、gli
Linux基礎知識之包管理工具
1、每12小時備份並壓縮/etc/目錄至/backup目錄中,儲存檔名稱格式為,“etc-年-月-日-時-分.tar.gz” [[email protected] backup]# tar -czv -f /backup/etc-"$(date
NPM:nodejs官方包管理工具的簡介、安裝、使用方法之詳細攻略
NPM之nodejs官方包管理工具的簡介 NPM的全稱是Node Package Manager,是隨同NodeJS一起安裝的包管理和分發工具,它很方便讓JavaScript開發者下載、安裝、上傳以及管理已經安裝的包。 npm是nodejs官方的一種包管理工具,簡單點來說,
linux之apt與dpkg安裝包管理工具的區別
一般來說linux系統主要分為兩大類: 1.RedHat系列:RedHat,Centos,Fedora等; 2.Debian系列:Debian,Ubuntu等; Dpkg(Debian系):Ubuntu RPM(RedHat系):Centos,Fedora RedHat
nodejs 之npm包管理工具詳解
npm--node package manager Node 檔案包管理工具 首先我還是喜歡man先生的解釋. npm <command> [args] 描述: npm 是Nodejs平臺的一個包管理工具.它將模組放在一個nodejs可以找到的地方.並
Golang專案管理實踐一--Golang包管理特點以及Glide工具的使用
文章內容 Golang包管理的特點 Golang包管理的注意點 結合Glide工具進行包管理實踐 總結 由於Golang特殊的包管理策略,同時,目前並沒有成熟的包管理工具,因此需要我們在管理Golang專案時,需要首先考慮適合專案的一種包管理策略,
Python包管理工具(pip)
too led -i min date pycuda nts nbsp env 1 前言 pip 是一個Python包管理工具,主要是用於安裝 PyPI 上的軟件包,可以替代 easy_install 工具。 GitHub: https://github.
Python包管理工具pip的基本使用
1.0 配置 .net 簡介 pac com 新的 png == 參考網址:https://pip.pypa.io/en/latest/quickstart/ 1.簡介 pip 是一個Python包管理工具,主要是用於安裝 PyPI 上的軟件包,可以替代 easy_inst
iOS包管理工具Cocoapods的安裝與使用
data == 鏡像 tracking libtool 們的 install 包管理 問題解決 在我們開發移動應用的時候,一般都會使用到第三方工具,而因為第三方類庫的種類繁多,我們在項目中進行管理也會相對麻煩,所以此時我們就須要一個包管理工具。在iOS開發中