现象
运行程序,报错:
example.go:3:8: cannot find module providing package github.com/gin-gonic/gin: working directory is not part of a module
Compilation finished with exit code 1
问题
未初始化模块
解决办法
F:\go\project_demo\gin_frame>go mod init
go: cannot determine module path for source directory F:\go\project_demo\gin_frame (outside GOPATH, module path must be specified)
Example usage:
'go mod init example.com/m' to initialize a v0 or v1 module
'go mod init example.com/m/v2' to initialize a v2 module
Run 'go help mod init' for more information.
F:\go\project_demo\gin_frame>go mod init example.com/m
go: creating new go.mod: module example.com/m