安装好gin后,main文件中如下:
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.GET("/", func(c *gin.Context) {
c.String(http.StatusOK, "hello")
})
router.Run(":8080")
}
页面打开localhost:8080即可