Getting Started
Go-Sail is a lightweight progressive golang web framework. It's extremely simple to get started - you only need a few lines of code to get up and running. Let's begin.
Getting Started
Installation
Requirements: Go version 1.20 or above.
go get -u github.com/keepchen/go-sail/v3
Launch Your Service
- Copy the following code into
main.go
main.go
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/keepchen/go-sail/v3/sail"
"github.com/keepchen/go-sail/v3/sail/config"
)
var (
conf = &config.Config{}
registerRoutes = func(ginEngine *gin.Engine) {
ginEngine.GET("/hello", func(c *gin.Context){
c.String(http.StatusOK, "%s", "hello, world!")
})
}
)
func main() {
sail.WakeupHttp("go-sail", conf).Hook(registerRoutes, nil, nil).Launch()
}
- Run command
go run main.go
- Open your browser and visit: localhost:8080/hello
- Screenshot:
- Your service is ready to go. Have fun! :)