安装iris时由于一些依赖包需要翻墙很可能导致安装不成功,解决办法如下
1.打开CMD命令提示框,设置临时环境变量(只在当前cmd窗口可用,设置环境变量永久解决)
set GO111MODULE=on
set GOPROXY=https://goproxy.io
注意 https://goproxy.io 也可替换成阿里云的 https://mirrors.aliyun.com/goproxy
go get -u github.com/kataras/iris
请用go env来查看GOPATH路径,具体安装位置,GOPATH/pkg/mod 目录中
在安装过程中可能会报如下错误:
go\pkg\mod\github.com\kataras\iris@v0.0.2\view\blocks.go:76:37: undefined: block
s.AssetFunc
go\pkg\mod\github.com\kataras\iris@v0.0.2\view\blocks.go:76:66: undefined: block
s.AssetNamesFunc
go\pkg\mod\github.com\kataras\iris@v0.0.2\view\blocks.go:77:10: s.Engine.Assets
undefined (type *blocks.Blocks has no field or method Assets)
解决办法: go get github.com/kataras/iris/v12@master
问题地址: https://github.com/kataras/iris/issues/1646