命令 功能
init 初始化 vendor 目录
list 列出所有的依赖包
add 添加包到 vendor 目录,如 govendor add +external 添加所有外部包
add PKG_PATH 添加指定的依赖包到 vendor 目录
update 从 $GOPATH 更新依赖包到 vendor 目录
remove 从 vendor 管理中删除依赖
status 列出所有缺失、过期和修改过的包
fetch 添加或更新包到本地 vendor 目录
sync 本地存在 vendor.json 时候拉去依赖包,匹配所记录的版本
get 类似 go get 目录,拉取依赖包到 vendor 目录
使用grpc进行开发时,启动grpc client报错如下:
panic: /debug/requests is already registered. You may have two independent copies of golang.org/x/net/trace in your binary, trying to maintain separate state. This may involve a vendored copy of golang.org/x/net/trace.
1
错误原因
golang.org/x/net/trace 在整个$GOPATH中有重复的副本,包括其他项目的vendor目录中依赖了golang.org/x/net包。
func init() {
_, pat := http.DefaultServeMux.Handler(&http.Request{URL: &url.URL{Path: debugRequestsPath}})
if pat == debugRequestsPath {
panic("/debug/requests is already registered. You may have two independent copies of " +
"golang.org/x/net/trace in your binary, trying to maintain separate state. This may " +
"involve a vendored copy of golang.org/x/net/trace.")
}
// TODO(jbd): Serve Traces from /debug/traces in the future?
// There is no requirement for a request to be present to have traces.
http.HandleFunc(debugRequestsPath, Traces)
http.HandleFunc(debugEventsPath, Events)
}
安装
go get -u github.com/kardianos/govendor
命令
init 创建 vendor 文件夹和 vendor.json 文件
list 列出已经存在的依赖包
add 从 $GOPATH 中添加依赖包,会加到 vendor.json
update 从 $GOPATH 升级依赖包
remove 从 vendor 文件夹删除依赖
status 列出本地丢失的、过期的和修改的package
fetch 从远端库增加新的,或者更新 vendor 文件中的依赖包
sync Pull packages into vendor folder from remote repository with revisions
migrate Move packages from a legacy tool to the vendor folder with metadata.
get 类似 go get,但是会把依赖包拷贝到 vendor 目录
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:
`+` package selection may be used with them
fmt, build, install, clean, test, vet, generate, tool