Home > Article > Backend Development > How to install golang gin
Gin is a web framework written in go, which implements APIs similar to the Martini framework with better performance.
# Install gin
stepping down in the command line (Recommended learning: Go )
go get -u github.com/gin-gonic/ginCheck whether the gin code package exists in /usr/local/go/path
Test whether Gin is installed successfully
package main import "github.com/gin-gonic/gin" func main() { r := gin.Default() r.GET("/ping", func(c *gin.Context) { c.JSON(200, gin.H{ "message": "pong", }) }) r.Run() // listen and serve on 0.0.0.0:8080 }
Execute test.go
go run test.goAccess $HOST:8080/ping, if {"message":"pong"} is returned, it is correct
curl 127.0.0.1:8080/pingAt this point, our environment installation is basically completed:)
The above is the detailed content of How to install golang gin. For more information, please follow other related articles on the PHP Chinese website!