簡介
太懶了,有時間再寫吧
安裝必須環境
我安裝go的博文連接點擊這裏,所以就不贅述。
iris安裝要求golang版本至少爲1.8,建議1.13(本文檔按照1.13進行編寫)
安裝iris
在安裝的時候記得打開GO111MODULE和使用中國代理
在項目路徑下設置環境變量
export GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
然後執行如下命令則是安裝iris
go get github.com/kataras/iris/v12@latest
這就是安裝好了
之後怎麼升級呢,例如升級到v12版本
go get -u github.com/kataras/iris/v12@latest
創建 helloworld
在項目目錄編寫一個main.go
package main
import (
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
app.Get("/", func(ctx iris.Context) {
ctx.HTML("<h1>Hello World!</h1>")
})
app.Run(iris.Addr(":8080"))
}
然後保存。
在命令行
go run main.go
輸出如下則成功。
Now listening on: http://0.0.0.0:8080
Application started. Press CTRL+C to shut down.
最後 在瀏覽器輸入IP:8080則可訪問