解决Beego安装过程中遇到的各种问题(亲测有效)

问题1

问题
 % go get -u github.com/beego/beego/v2
package github.com/beego/beego/v2: cannot find package "github.com/beego/beego/v2" in any of:
    /usr/local/go/src/github.com/beego/beego/v2 (from $GOROOT)
    /Users/guands/go/src/github.com/beego/beego/v2 (from $GOPATH)
解决办法

添加环境变量
低版本: export GO111MODULE=on
高版本: go env -w GO111MODULE=on


问题2

问题

go get网络太慢

解决办法

添加环境变量
低版本: export GOPROXY=https://goproxy.cn
高版本: go env -w GOPROXY=https://goproxy.cn


问题3

问题
go: github.com/codahale/[email protected]: parsing go.mod: unexpected module path "github.com/HdrHistogram/hdrhistogram-go"
go: gopkg.in/[email protected]: go.mod has non-....v1 module path "github.com/fsnotify/fsnotify" at revision v1.6.0
go: github.com/circonus-labs/[email protected]: parsing go.mod: unexpected module path "github.com/openhistogram/circonusllhist"
go: github.com/lyft/[email protected]: parsing go.mod: unexpected module path "github.com/envoyproxy/protoc-gen-validate"

go: github.com/siddontang/[email protected]: parsing go.mod: unexpected module path "github.com/ledisdb/ledisdb"
go: github.com/go-check/[email protected]: parsing go.mod: unexpected module path "gopkg.in/check.v1"

go get: error loading module requirements
解决办法

主要是依赖的路径发生了变化, 修改go.mod文件内容, 按照如下格式追加replace:

replace (
	github.com/circonus-labs/circonusllhist => github.com/openhistogram/circonusllhist v0.3.0
	github.com/codahale/hdrhistogram => github.com/HdrHistogram/hdrhistogram-go v1.1.2
	github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.6
	github.com/lyft/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.6.13
	
	github.com/siddontang/ledisdb => github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6
	github.com/go-check/check => gopkg.in/check.v1 v0.0.0-20201130134442-10cb98267c6c
)

问题4

问题
package github.com/hashicorp/hcl/hcl/printer: cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:
        /usr/local/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOROOT)
        /Users/guands/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOPATH)
解决办法

在项目目录下执行命令:
go get -u github.com/hashicorp/hcl

你可能感兴趣的:(Go,beego)