0%

Qihoo360 Wayne backend启动时报错cannot load github.com/modern-go/reflect2

Qihoo360 Wayne的文件目录为/Development/wayne

运行bee run命令时,会遇到如下错误。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
cd src/backend

bee run -runargs=apiserver
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2019/08/10 08:17:53 WARN ▶ 0001 Running application outside of GOPATH
2019/08/10 08:17:53 INFO ▶ 0002 Using 'backend' as 'appname'
2019/08/10 08:17:53 INFO ▶ 0003 Initializing watcher...
Fetching https://goproxy.io/github.com/modern-go/reflect2/@v/list
Fetching https://goproxy.io/sigs.k8s.io/yaml/@v/list
Fetching https://goproxy.io/sigs.k8s.io/@v/list
Fetching https://goproxy.io/github.com/modern-go/@v/list
Fetching https://goproxy.io/github.com/@v/list
build github.com/Qihoo360/wayne/src/backend: cannot load github.com/modern-go/reflect2: cannot find module providing package github.com/modern-go/reflect2
2019/08/10 08:17:55 ERROR ▶ 0004 Failed to build the application: build github.com/Qihoo360/wayne/src/backend: cannot load github.com/modern-go/reflect2: cannot find module providing package github.com/modern-go/reflect2

解决方法,在终端先执行如下命令,以GO MODULE的方式加载包,即可以正常运行。

1
2
export GO111MODULE=on   // mac, linux
set $GO111MODULE=on // windows
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
bee run -runargs=apiserver
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2019/08/10 08:19:26 WARN ▶ 0001 Running application outside of GOPATH
2019/08/10 08:19:26 INFO ▶ 0002 Using 'backend' as 'appname'
2019/08/10 08:19:26 INFO ▶ 0003 Initializing watcher...
Fetching https://goproxy.io/sigs.k8s.io/yaml/@v/list
Fetching https://goproxy.io/github.com/modern-go/reflect2/@v/list
2019/08/10 08:19:35 SUCCESS ▶ 0004 Built Successfully!
2019/08/10 08:19:35 INFO ▶ 0005 Restarting 'backend'...
2019/08/10 08:19:35 SUCCESS ▶ 0006 './backend' is running...
2019/08/10 08:19:35.057 [D] [db.go:75] Initialize database connection: ****:root@tcp(127.0.0.1:3306)/
2019/08/10 08:19:35.076 [I] [asm_amd64.s:1337] http server Running on http://:8080
2019/08/10 08:19:35.076 [I] [asm_amd64.s:1337] Admin server Running on :8088

如果有些包下载不了,还可以设置GOPROXY环境变量。

1
2
export GOPROXY=https://goproxy.io       // mac, linux
set $GOPROXY=on // windows