可以使用 https://pkg.go.dev/ 搜索go三方库
- 下载golang安装包
go1.24.1.windows-amd64.msi 5968e7adcf26e68a54f1cd41ad561275a670a8e2ca5263bc375b524638557dfb
>certutil -hashfile go1.24.1.windows-amd64.msi MD5
MD5 hash of go1.24.1.windows-amd64.msi:
f29258b4b01a6906b6d99e76bb8a29e7
CertUtil: -hashfile command completed successfully.
>certutil -hashfile go1.24.1.windows-amd64.msi SHA256
SHA256 hash of go1.24.1.windows-amd64.msi:
5968e7adcf26e68a54f1cd41ad561275a670a8e2ca5263bc375b524638557dfb
CertUtil: -hashfile command completed successfully.
go version
go version go1.24.1 windows/amd64
- 设置环境变量
- GOROOT 指向golang安装路径 (C:\Program Files\Go)
- GOPATH 本地所有 Go 项目的根目录,在目录下创建三个文件夹 src、bin、pkg (C:\Go)
- 在 src 目录下创建 github.com / morningcat2018 目录,并在下面创建项目路径如
demoProject - 在项目路径下执行
go mod init demoProject & go mod tidy
- 在 src 目录下创建 github.com / morningcat2018 目录,并在下面创建项目路径如
- 设置代理
go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy,direct
# 默认为 https://proxy.golang.org,direct
- 阿里云:
https://mirrors.aliyun.com/goproxy - 微软:
https://goproxy.io - 七牛云:
https://goproxy.cn - GoCenter:
https://gocenter.io
- 安装第三方包
gin 安装
go get -u
github.com/gin-gonic/gin
gorm 安装 https://gorm.io/zh_CN/docs/
go get -u
gorm.io/gorm
go get -u
gorm.io/driver/sqlite