当前位置:网站首页>如何安装govendor并打开项目
如何安装govendor并打开项目
2022-07-25 16:18:00 【Melody2050】
安装govendor
参考Go Dependencies via govendor
English
使用go 1.18,在任意目录执行go install安装govendor
go install github.com/kardianos/[email protected]
将项目放置到$GOPATH/src1,在项目内列出依赖列表
govendor list
可以看到该项目内的各种依赖
...
l moby/volume
l moby/volume/drivers
l moby/volume/local
l moby/volume/mounts
l moby/volume/service
l moby/volume/service/opts
l moby/volume/testutils
m appengine
m appengine_internal
m appengine_internal/base
之后对每个没下载的依赖执行fetch即可:
govendor fetch github.com/docker/docker/pkg/reexec
govendor fetch github.com/docker/docker/rootless
...
不过用fetch的做法有点低效,笔者还没找到其他高效做法
踩坑
下载govendor失败
a connection attempt failed because the connected party did not properly respond after period of tim
GO A connection attempt failed because the connected party did not properly respond after a period…
如果go install下载失败,需要修改go的代理为国内镜像
go env -w GOPROXY=https://goproxy.cn
govendor路径错误
govendor error package not a go package or not in gopath
你的项目没有放置在$GOPATH/src。
首先执行go env GOPATH查看路径,如果是不符合预期的,就参考windows11 如何修改环境变量,修改GOPATH系统变量。
删除govendor依赖
使用govendor fetch github.com/spf13/cobra来下载依赖,并到$GOPATH/.cache下删除依赖。
拉取不到指定分支
执行了govendor fetch命令后, 报错如下
D:\codes\src\moby>govendor fetch github.com/spf13/cobra
# cd D:\codes\.cache\govendor\github.com\spf13\cobra; git reset --hard origin/master
fatal: ambiguous argument 'origin/master': unknown revision or path not in the working tree
.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Error: failed to sync to latest revision exit status 128
Failed to fetch package "github.com/spf13/cobra"
可以看到,govendor尝试执行git reset --hard origin/master,但找不到这个分支,因为原仓库本来就没这个分支

所以改为运行后,执行成功
govendor fetch github.com/spf13/[email protected]
参考Go Vendoring Beginner Tutorial的相关说明,提到
Go to your project directory (it must be in the GOPATH src)可知,项目必须在GOPATH的src目录下。 ︎
边栏推荐
猜你喜欢

tkinter模块高级操作(一)—— 透明按钮、透明文本框、自定义按钮及自定义文本框

Solve win10 disk occupation of 100%

Cookie、cookie与session区别

阿唐的小帮手

论文笔记:Highly accurate protein structure prediction with AlphaFold (AlphaFold 2 & appendix)

Waterfall flow layout

Analysis and solution of data and clock mismatch delay in SPI transmission

泰雷兹推出解决方案,助力SAP客户控制云端数据

一文理解分布式开发中的服务治理

Product dynamics - Android 13 high-efficiency adaptation new upgrade
随机推荐
Equivalent change of resistance circuit (Ⅱ)
fastadmin tp 安装使用百度富文本编辑器UEditor
Recommended collection, which is probably the most comprehensive coding method summary of category type features
记得那两句话
Record Locks(记录锁)
Shared lock
How to build an enterprise level OLAP data engine for massive data and high real-time requirements?
论文笔记:Highly accurate protein structure prediction with AlphaFold (AlphaFold 2 & appendix)
Today, I went to oppo for an interview and was asked numbly
Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
Exclusive lock
Doget and dopost
今天睡眠质量记录84分
01. A simpler way to deliver a large number of props
ServletConfig 类和ServletContext 类
Analysis and solution of data and clock mismatch delay in SPI transmission
Mysql读写锁
Mqtt x cli officially released: powerful and easy-to-use mqtt 5.0 command line tool
General test case writing specification
权限管理-角色分配菜单