Vendor

简介: vendor踩坑笔记:

vendor踩坑笔记:


接过公司里面X平台golang部分的后端后,需要新添加一个业务功能,美滋滋~ 拿过项目一顿写之后后遇到事了。


报错的描述如下:



报错的大意说:方法的入参类型不匹配,我们不能把 Assignment2/vendor/github.com/... 当作github.com/... 类型来使用。

出现的这个错误的原因就项目中使用的 beego的Controller使用了vendor进行管理,于是在这个包前多了个前缀 项目名/vendor/xxx。但是呢,这个函数需要的是纯粹的beego的controller,加上这个前缀之后反到是不认识了。于是就出现了上面的错误。

查阅资料后了解:vendor是在GOPATH的管理之下的,大白话说:如果我们的项目在GOPATH目录下,那么项目中需要的依赖信息优先从vendor中获取。你看,我上面的报错就属于这个情况,我以为我在使用 github/astaxie/beego/controller , 而实际优先导入了 项目名/vendor/github/astaxie/beego/controller


当时我是如何解决的呢?


不是说优先导入vendor中的代码吗?好,我把你删除,你不就使用我本地的依赖了?(纯洁的微笑~)

事实证明,确实如此,删除vendor中的依赖后,一切归于平静,继续开发~

但是我提交代码让组里的大佬CR时,大佬发现vendor被我改了~~~,这才知道,项目之所以使用vendor管理项目就是为了让项目中的依赖可以跟着项目迁移,这样部署项目时不再去很多不同的地方拉取依赖,因为依赖都在项目里面。


所以删除vendor中的依赖并不是万全之策,可以删掉现在的vendor,重新用vendor初始化一下,让项目中的依赖重新让vendor管理。


# 下载govendor
 go get -u -v github.com/kardianos/govendor
 # 在当前目录中执行如下命令进行初始化,将依赖加入vendor统一管理
 govendor init
 govendor add +e
相关文章
Ninja is required to load C++ extensions | 问题解决
Ninja is required to load C++ extensions | 问题解决
|
Python
解决loaded more than 1 DLL from .libs和No metadata found in lib\site-packages两个错误
解决loaded more than 1 DLL from .libs和No metadata found in lib\site-packages两个错误
342 0
|
IDE 开发工具 数据库
STM32bug【 KEILMDK中出现The Project references devices, files or libraries that are not installed】
STM32bug【 KEILMDK中出现The Project references devices, files or libraries that are not installed】
179 0
MAC编译lame ld: symbol(s) not found for architecture x86_64/_lame_init_old“, referenced from
MAC编译lame ld: symbol(s) not found for architecture x86_64/_lame_init_old“, referenced from
210 0
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64
65 0
|
Python
【解决方案】解决CMake must be installed to build the following extensions: pyltp
【解决方案】解决CMake must be installed to build the following extensions: pyltp
166 0
成功解决OpenVideoCall(不可用)以及MSB8020 The build tools for v141 (Platform Toolset = ‘v141‘) cannot be found
成功解决OpenVideoCall(不可用)以及MSB8020 The build tools for v141 (Platform Toolset = ‘v141‘) cannot be found
成功解决OpenVideoCall(不可用)以及MSB8020 The build tools for v141 (Platform Toolset = ‘v141‘) cannot be found
|
API iOS开发 容器
App Extensions篇之Share Extension
这里主要是对App Extension的一些介绍以及详细给大家介绍一下Share Extension,后期会添加其他的Extension介绍。
3288 0
|
API 开发工具 Android开发
Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
811 0
Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

热门文章

最新文章