GO语言 Iris框架下载安装测试指南 排除故障 非GoMod模式

因为在局域网下下载Iris框架可能会遇到一些困难

首先提供上Iris项目GitHub地址:https://github.com/kataras/iris
网络上提供 了许多下载方法 都是类似于go get -u github.com/katars/iris
但是我发现这个命令输入完后可能会遇到假死(终端没有反应)
其实它是在后台进行下载 所以我们可以加上-v 来显示详细内容
代码如下go get -u -v github.com/kataras/iris
执行后显示如下即为开始下载

github.com/kataras/iris (download)
github.com/BurntSushi/toml (download)
github.com/kataras/golog (download)
github.com/kataras/pio (download)
github.com/Shopify/goreferrer (download)

但是如果你是小白你可能会遇到如下问题:
1、在执行go get -u -v github.com/kataras/iris时提示

go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/kataras/iris: exec: "git": executable file not found in $PATH

这是提示你的环境下Git配置不正确或者Git没有安装(多半是没有安装这个原因)
你只需要去安装Git即可
CentOs直接给出命令sudo yum install git
2、这是我遇到的问题

unrecognized import path "golang.org/x/net/publicsuffix": https fetch: Get "https://golang.org/x/net/publicsuffix?go-get=1": dial tcp 216.239.37.1:443: i/o timeout

我个人理解为是大陆局域网无法访问到golang.org这个网址 无法获取到所需的附属资源
我自己遇到是缺少三个大项目

1、golang.org/x/net/
2、golang.org/x/text/
3、golang.org/x/crypto/

但是Golang.org在Github上是有镜像的
这三个对应的Github项目地址如下:

1=https://github.com/golang/net
2=https://github.com/golang/text
3=https://github.com/golang/crypto

所以问题就很好解决了
只需要在我们Go的%Path%/src/golang.org/x/目录下执行三条命令
如果没有这些目录 就自己创建 一般是有golang.org但没有其下子目录

1、git clone https://github.com/golang/net.git
2、git clone https://github.com/golang/text.git
3、git clone https://github.com/golang/crypto.git

即可从Github上克隆我们运行Iris框架所缺的文件
执行后应该有这么三个文件夹
在这里插入图片描述
给出小贴士:
查看GOPATH目录
linux系统在终端执行go env
即可看到有这么一行GOPATH="/home/zpolari/go"等号后面就是你的GOPATH目录

在执行完上述命令后
我们的%gopath%/src下应该有
在这里插入图片描述
这些文件夹里面都有若干项需要的文件夹

测试Iris是否安装成功
在main.go运行如下代码

package main

import "github.com/kataras/iris"

func main() {
	app:=iris.New()//创建一个Iris对象
	app.Run(iris.Addr(":8889"))//运行Iris监听服务
}

如果运行后终端没有报错且提示如下内容:

Now listening on: http://localhost:8889
Application started. Press CTRL+C to shut down.

恭喜你!Iris框架安装成功
如果提示其他内容 可以留言 我会尽所能的帮助你

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值