zzh@ZZHPC:~/zd/Github/RepoGo$ go work init zzh@ZZHPC:~/zd/Github/RepoGo$ cd web-service-gin/ zzh@ZZHPC:~/zd/Github/RepoGo/web-service-gin$ go mod init github.com/ZhangZhihuiAAA/RepoGo/web-service-gin zzh@ZZHPC:~/zd/Github/RepoGo/web-service-gin$ cd .. zzh@ZZHPC:~/zd/Github/RepoGo$ go work use ./web-service-gin
go.mod names the module name.
go.work uses the names of the directories of the modules.
zzh@ZZHPC:/zdata/Github$ go work init zzh@ZZHPC:/zdata/Github$ go work use ./zimplebank zzh@ZZHPC:/zdata/Github$ go work use ./orders-api zzh@ZZHPC:/zdata/Github$ code .
This go.sum file contains the cryptographic checksums representing the content of the required packages.
The go.sum file isn’t designed to be human-editable and generally you won’t need to open it. But it serves two useful functions:
- If you run the go mod verify command from your terminal, this will verify that the checksums of the downloaded packages on your machine match the entries in go.sum, so you can be confident that they haven’t been altered.
$ go mod verify all modules verified
- If someone else needs to download all the dependencies for the project — which they can do by running go mod download — they will get an error if there is any mismatch between the packages they are downloading and the checksums in the file.
So, in summary:
- You (or someone else in the future) can run go mod download to download the exact versions of all the packages that your project needs.
- You can run go mod verify to ensure that nothing in those downloaded packages has been changed unexpectedly.
- Whenever you run go run , go test or go build , the exact package versions listed in go.mod will always be used.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律