首页 > 其他分享 >Go - Requiring Local Versions of Dependent Packages

Go - Requiring Local Versions of Dependent Packages

时间:2023-09-29 09:12:16浏览次数:42  
标签:vendor Versions Dependent Requiring dependent go Go packages mod

Problem: You want to use local versions of the dependent packages.


Solution: Set up Go to use a vendor directory by running go mod vendor.


Local versions are the specific version of the dependent packages that you can use and are a safeguard in case the originals disappear (it happens). Having local versions of the dependent packages can be useful (and not only because you have trust issues). Run this from the command line to download and keep local versions of the dependent packages:

$ go mod vendor

This will create a vendor subdirectory in your project directory and populate it with the dependencies from your go.mod file. It also creates a vendor/modules.txt file that contains a listing of the packages you have just vendored and the versions they were copied from.

By default, Go will use the version in the vendor directory if your Go version is 1.1.4 and above and your vendor/modules.txt file is in sync with your go.mod file.

If you want to enable vendoring explicitly, you can include the - mod vendor flag in the go command.
For example, to build the project, you will do this:
# go build - mod vendor

If you want to disable vendoring explicitly, include the - mod readonly or - mod mod in the go command.
What happens if you add a new dependent package after you have vendored the module? If go.mod has changed since modules.txt was generated, the go command will show an error, and you should update the vendor directory again by running go mod vendor .

标签:vendor,Versions,Dependent,Requiring,dependent,go,Go,packages,mod
From: https://www.cnblogs.com/zhangzhihui/p/17736772.html

相关文章

  • ERROR: Could not find a version that satisfies the requirement selunium (from ve
    错误信息ERROR:Couldnotfindaversionthatsatisfiestherequirementselenium(fromversions:none)ERROR:Nomatchingdistributionfoundforselenium解决方案方法1:增大超时时间pip--default-timeout=100installselenium方法2:修改安装源为清华安装源pipi......
  • PIM-DM:Protocol Independent Multicast-Dense Mode
    建立连接的过程1、hello报文(30s)2、扩展3、prune修剪4、断言机制5、嫁接6、刷新(105s)......
  • AtCoder Grand Contest 023 E Inversions
    洛谷传送门AtCoder传送门首先将\(a\)从小到大排序,设\(p_i\)为排序后的\(a_i\)位于原序列第\(p_i\)个位置,\(x_i\)为要填的排列的第\(i\)个数。设\(A=\prod\limits_{i=1}^n(a_i-i+1)\),则\(A\)为排列的总方案数(考虑按\(a_i\)从小到大填即得)。套路地,统......
  • 题解 P5426 [USACO19OPEN]Balancing Inversions G
    来一篇简单易懂的良心题解。由于数值不是\(0\)就是\(1\),我们可以考虑将逆序对的统计方式化简。以左区间为例,设\(x\)为\(1\)的个数,\(p_i\)为第\(i\)个\(1\)的坐标,则逆序对个数为\(\sum\limits_{i=1}^{x}n-p_i-(x-i)\)。也就是\((n-x)\cdotx+\frac{x\cdot(x+1)}{......
  • You don't have write permissions for the /System/Library/Frameworks/Ruby.framewo
    GemErrorERROR: Whileexecutinggem...(Gem::FilePermissionError)  Youdon'thavewritepermissionsforthe/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0directory. 解决办法: ......
  • this version of the Java Runtime only recognizes class file versions up to 55.0
    问题:  运行SpringBootdemo时报错: thisversionoftheJavaRuntimeonlyrecognizesclassfileversionsupto55.0at原因:   编译版本和运行版本不一致,具体原因是编译版本高于运行版本,SpringBootdemo中使用的是jdk17,我本地的jdk是11 解决:  调整idea中的jd......
  • CF1637H Minimize Inversions Number
    我直接??????????????????考虑一个数怎么做,就是逆序对减去一个\(i\)前面的逆序对再加上顺序对。考虑很多数怎么做,就是这个玩意的和再加上子序列种的顺序对减去逆序对,顺序对可以用逆序对表示,现在只考虑顺序对。注意到,如果\(i<j,p_i>p_j\)且\(i\)在子序列中\(j\)不在子序列中,那么把\(j\)弄......
  • this version of the Java Runtime only recognizes class file versions up to 52.0
    在SAPCommerceCloudBackoffice做fullindexing时,遇到错误消息:ERROR:Errorfromserverathttps://localhost:8983/solr:ErrorCREATEingSolrCore'master_backoffice_backoffice_product_flip':Unabletocreatecore[master_backoffice_backoffice_product......
  • 【cpluplus教程翻译】类型转换(Type conversions)
    隐式类型转换(implicitconversion)如果一个值被拷贝到另一个兼容类型中,隐式类型转换会自动执行(注意对象指针引用的区别)。比如shorta=2000;intb;b=a;a的值从short被提升到int,这个过程不需要显式的转换,这被称为标准转换(standardconversion),标准转换针对的是基础数据类型,数......
  • Spring:Formatter 和 ConversionService 的区别?
    在Spring框架中,Formatter和ConversionService是两个独立的概念,并没有直接的继承关系。Formatter接口和ConversionService接口是在不同的包中定义的,它们有着不同的目的和功能。Formatter接口位于org.springframework.format包中,用于格式化和解析字段值,并提供了本地化、格式化选项......