环境
PS D:\Code\Go> go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=D:\Code\Go\bin
set GOCACHE=C:\Users\weize\AppData\Local\go-build
set GOENV=C:\Users\weize\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\Code\Go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\Code\Go\
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.5
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\weize\AppData\Local\Temp\go-build2180335972=/tmp/go-build -gno-record-gcc-switches
开启mod支持
go env -w GO111MODULE=on
设置proxy
go env -w GOPROXY=https://goproxy.cn,direct
安装beego
go get github.com/astaxie/beego
常见问题
1、git https校验不通过,关闭https验证
git config --global http.sslVerify false
安装bee【工具】
go get github.com/beego/bee
常见问题
1、安装成功后无法使用,请在环境变量中加入GOBIN,并在PATH中加入GOBIN目录
![image.png](https://img-blog.csdnimg.cn/img_convert/fc1dbf94027d2b845f2034fb4ead25b6.png#clientId=u7f51b8ab-26d1-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=40&id=uf5574b9c&margin=[object Object]&name=image.png&originHeight=80&originWidth=945&originalType=binary&ratio=1&rotation=0&showTitle=false&size=9542&status=done&style=none&taskId=u837162d3-2cbc-4781-b63f-1c5162b4323&title=&width=472.5)
新建beego项目
bee new beegoProject
进入项目目录
cd ./beegoProject
运行beego项目
PS D:\Code\Go\src\beegoProject> bee run
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.12.0
2022/04/19 11:13:37 INFO ▶ 0001 Using 'beegoProject' as 'appname'
2022/04/19 11:13:37 INFO ▶ 0002 Initializing watcher...
github.com/shiena/ansicolor
github.com/astaxie/beego/config
gopkg.in/yaml.v2
github.com/astaxie/beego/toolbox
github.com/astaxie/beego/grace
github.com/astaxie/beego/session
github.com/astaxie/beego/logs
github.com/astaxie/beego/context
github.com/astaxie/beego/context/param
github.com/astaxie/beego
beegoProject/controllers
beegoProject/routers
beegoProject
2022/04/19 11:13:42 SUCCESS ▶ 0003 Built Successfully!
2022/04/19 11:13:42 INFO ▶ 0004 Restarting 'beegoProject.exe'...
2022/04/19 11:13:42 SUCCESS ▶ 0005 './beegoProject.exe' is running...
2022/04/19 11:13:43.680 [I] [asm_amd64.s:1581] http server Running on http://:8080
常见问题
2022/04/19 11:11:55 ERROR ▶ 0003 Failed to build the application: controllers\default.go:4:2: missing go.sum entry for module providing package github.com/astaxie/beego (imported by beegoProject); to add:
go get beegoProject
解决
解决方案一:
当在代码中使用了第三方库 ,但是go.mod中并没有跟着更新的时候
如果直接run或者build就会报这个错误
missing go.sum entry for module providing package <package_name>
可以使用go mod tidy 来整理依赖
这个命令会:
删除不需要的依赖包
下载新的依赖包
更新go.sum
解决方案二:
go build -mod=mod
本人遇到同样的问题,就是用方案解决的。