Golang包管理工具之govendor的使用

2021-08-21 04:53:20 字數 3961 閱讀 4964

本文個人部落格位址為:

本文個人部落格位址為:

更多golang包管理工具參考 golang包管理工具之glide的使用

常用的依賴包管理工具有godepgovendor等,在golang1.5之後,go提供了go15vendorexperiment環境變數(go 1.6版本預設開啟該環境變數),用於將go build時的應用路徑搜尋調整成為當前專案目錄/vendor目錄方式。通過這種形式,我們可以實現類似於godep方式的專案依賴管理。

go get -u

-v github.com/kardianos/govendor

#進入到專案目錄

cd /home/gopath/src/mytool

#初始化vendor目錄

govendor init

#檢視vendor目錄

[root@cc54425a 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

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

thegiven status or import paths.

shell run a "shell"

to make multiple sub-commands more efficient for large

projects.

"+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

notin 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

[::][@]

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

aslast

character) to exclude when copying files in

the vendor folder.

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

isset.

govendor配置檔案,記錄依賴包列表。

],"rootpath": "mytool"

}

Golang包管理工具之govendor的使用

常用的依賴包管理工具有godep,govendor等,在golang1.5之後,go提供了go15vendorexperiment環境變數 go 1.6版本預設開啟該環境變數 用於將go build時的應用路徑搜尋調整成為當前專案目錄 vendor目錄方式。通過這種形式,我們可以實現類似於godep...

包管理工具

參考 yum和apt get的區別 rpm命令詳解及和yum之間的關係 centos中rpm和yum到底有什麼區別?dpkg和apt get區別 dpkg 常用指令操作快速參考 yum和apt get常用命令 linux分類 一般著名的linux系統基本分成兩大類 1 redhat系列 redhat...

Python之包管理工具

安裝python包的過程中,經常涉及到distutils setuptools distribute setup.py easy install easy install和pip等等。distutils 是 python 標準庫的一部分,這個庫的目的是為開發者提供一種方便的打包方式,同時為使用者提供...