Quick start

  1. # assume the following codes in example.go file
  2. $ cat example.go
  1. package main
  2. import "github.com/gin-gonic/gin"
  3. func main() {
  4. r := gin.Default()
  5. r.GET("/ping", func(c *gin.Context) {
  6. c.JSON(200, gin.H{
  7. "message": "pong",
  8. })
  9. })
  10. r.Run() // listen and serve on 0.0.0.0:8080
  11. }
  1. # run example.go and visit 0.0.0.0:8080/ping on browser
  2. $ go run example.go