官方文档:https://www.iris-go.com/docs
安装Iris
首先,创建一个项目文件夹——hello-server,在文件夹中输入以下命令。
E:\hello-server>go mod init hello-server
E:\hello-server>go get github.com/kataras/iris/v12@master
如果遇到网络错误,就输入以下命令。
E:\hello-server>go env -w GOPROXY=https://goproxy.cn,https://gocenter.io,https://goproxy.io,direct
搭建一个简单的服务端
打开这个项目,新建一个main文件夹,并在其下创建hello.go文件,并在该文件中写入以下代码。
package main
import "github.com/kataras/iris/v12"
func main() {
app := iris