错误集合
1. 安装 beego
问题:
➜ go go get github.com/astaxie/beego
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
解决:
上面的情况是go的环境设置问题,执行
go env -w GO111MODULE=auto
后执行
go get github.com/astaxie/beego
改变环境问题后续还是会有问题
../../pkg/mod/golang.org/x/sys@v0.0.0-20191005200804-aed5e4c7ecf9/unix/zsyscall_darwin_amd64.go:90:3: //go:linkname must refer to declared function or variable
../../pkg/mod/golang.org/x/sys@v0.0.0-20191005200804-aed5e4c7ecf9/unix/zsyscall_darwin_amd64.go:105:3: //go:linkname must refer to declared function or variable
../../pkg/mod/golang.org/x/sys@v0.0.0-20191005200804-aed5e4c7ecf9/unix/zsyscall_darwin_amd64.go:121:3: //go:linkname must refer to declared function or variable
../../pkg/mod/golang.org/x/sys@v0.0.0-20191005200804-aed5e4c7ecf9/unix/zsyscall_darwin_amd64.go:121:3: too many errors
后续使用 mod 管理
创建新项目
cd 新项目
mod init
go get github.com/beego/bee/v2
export PATH=$PATH:<your_main_gopath>/bin
不知道哪一步出问题,还是没有生成 bee 可执行文件。手动编译项目移动到 go 文件下 bin
cd github.com/beego/bee
//直接编译源码
go build -o bee
//移动 bee 文件到 gopath /bin
2. beego路由 404
成功运行项目,调用接口报 404
//重新执行生成路由
bee generate routers
网友评论