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
执行go example 报异常,根据网上提示可以这样解决
F:\go\project_1\gin_frame>go mod init
go: cannot determine module path for source directory F:\go\project_1\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_1\gin_frame>go mod init example.com/m
go: creating new go.mod: module example.com/m
自己可以根据相应的提示进行操作
go mod init example.com/m
网友评论