[英]What does this command do 'GOFLAGS=-mod=mod'?
I am trying to make a Taskfile.yml file for building go application, but I can't quite understand the need of "GOFLAGS=-mod=mod" command before go build main.go.我正在尝试制作一个用于构建 go 应用程序的 Taskfile.yml 文件,但我不太明白在 go build main.go 之前需要“GOFLAGS=-mod=mod”命令。
reference: https://dev.to/aurelievache/learning-go-by-examples-part-3-create-a-cli-app-in-go-1h43参考: https://dev.to/aurelievache/learning-go-by-examples-part-3-create-a-cli-app-in-go-1h43
So there are two things here所以这里有两件事
GOFLAGS
GOFLAGS
variable has a space separated list of flags that will automatically be passed to the appropriate go commands.GOFLAGS
变量有一个空格分隔的标志列表,这些标志将自动传递给适当的 go 命令。mod
, this flag is applicable to the go build
command and may not be applicable to other go commands.mod
,这个标志适用于go build
命令,可能不适用于其他 go 命令。go
does this, refer to this change requestgo
是如何做到这一点的,请参阅此更改请求-mod=mod
flag, actually do during go build
?-mod=mod
标志在go build
期间实际上做了什么?
-mod
flag controls whether go.mod may be automatically updated and whether the vendor directory is used. -mod
标志控制 go.mod 是否可以自动更新以及是否使用供应商目录。-mod=mod
tells the go command to ignore the vendor directory and to automatically update go.mod, for example, when an imported package is not provided by any known module. -mod=mod
告诉 go 命令忽略供应商目录并自动更新 go.mod,例如,当任何已知模块未提供导入的 package 时。 Therefore所以
GOFLAGS="-mod=mod" go build main.go
is equivalent to相当于
go build -mod=mod main.go
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.