Golang:Module And Goland配置

go help modules

go mod命令

download    download modules to local cache (下载依赖的module到本地cache))
edit        edit go.mod from tools or scripts (编辑go.mod文件)
graph       print module requirement graph (打印模块依赖图))
init        initialize new module in current directory (再当前文件夹下初始化一个新的module, 创建go.mod文件))
tidy        add missing and remove unused modules (增加丢失的module,去掉未用的module)
vendor      make vendored copy of dependencies (将依赖复制到vendor下)
verify      verify dependencies have expected content (校验依赖)
why         explain why packages or modules are needed (解释为什么需要依赖)

初始化mod

go mod init [module]可以创建一个go.mod,只有一行信息module。

打开 Goland->File->Settings->Tool->External Tool

Name: InitModule
Program: C:\Go\bin\go.exe
Arguments: mod init $FileDirName$
Working directory: $FileDir$
Name: RefreshModuleDependencies
Program: C:\Go\bin\go.exe
Argument: mod tidy
Working Diretory: $FileDir$
Name: CleanModuleCache
Program: C:\Go\bin\go.exe
Argument: clean -modcache
Working Diretory: 
Name: DownloadModuleDepenencies
Program: C:\Go\bin\go.exe
Argument: mod download
Working Diretory: 
Name: CopyModuleDependencies
Program: C:\Go\bin\go.exe
Argument: mod vendor
Working Diretory: $FileDir$

参考:

https://studygolang.com/articles/17548

Golang代理 : https://blog.csdn.net/halo_hsuh/article/details/105812077

猜你喜欢

转载自blog.csdn.net/halo_hsuh/article/details/106213176