Skip to content

安装

安装

go
go get -u github.com/gin-gonic/gin

使用

go
import "github.com/gin-gonic/gin"
import "net/http"

例子:输出"hello world"

go
package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	// 1、创建路由
	g := gin.Default()
	// 2、绑定路由规则,执行视图函数
	g.GET("/", func(c *gin.Context) {
		// 3、返回值
		c.String(http.StatusOK,"hello world")
	})
	// 4、开启监听
	g.Run(":8000")
}

a5edf11d1e50534ef809fa4b09dfea0c MD5

最近更新