mirror of
https://gitea.com/action-examples/Go.git
synced 2026-03-27 08:30:06 +00:00
build: add Go module and basic HTTP server using gin-gonic/gin
- Add a new file `go.mod` with the content of a Go module - Specify the module name as `example` - Specify the Go version as `1.21.2` - Add a requirement for the package `github.com/gin-gonic/gin` with version `v1.9.1` - Add multiple indirect requirements for various packages - Add a new file `main.go` with a basic Go program using the `gin-gonic/gin` package to create an HTTP server Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
20
main.go
Normal file
20
main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
r.GET("/ping", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "pong",
|
||||
})
|
||||
})
|
||||
// listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
|
||||
if err := r.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user