v1.1.0Declarative config, service calls & hot reload

Spring Boot, for Go.

Ginboot is an enterprise-ready Go web framework built on Gin. Database-agnostic repositories, AWS Lambda, OpenTelemetry and declarative configuration — all out of the box.

go get -u github.com/klass-lk/ginboot

Controllers, not boilerplate

Register a controller and return typed DTOs. Ginboot wires up binding, error handling, tracing and serialisation — and the same code runs as an HTTP server or a Lambda function.

main.go
package main

import (
	"log"

	"github.com/klass-lk/ginboot"
	"github.com/klass-lk/ginboot/example/internal/controller"
)

func main() {
	// Loads ginboot.yml / application.yml and .env automatically
	server := ginboot.New()
	cfg := server.Config()

	server.SetBasePath(cfg.Ginboot.Server.BasePath)
	server.RegisterController("/posts", controller.NewPostController(svc))

	// Runs as HTTP locally, as an API Gateway proxy on AWS Lambda
	if err := server.Start(cfg.Ginboot.Server.Port); err != nil {
		log.Fatal(err)
	}
}
post_controller.go
package controller

import "github.com/klass-lk/ginboot"

func (c *PostController) Register(group *ginboot.ControllerGroup) {
	group.GET("/:id", c.GetPost)

	protected := group.Group("")
	protected.POST("", c.CreatePost)
}

// Handlers return (DTO, error) — Ginboot handles binding,
// status codes and JSON serialisation for you.
func (c *PostController) GetPost(ctx *ginboot.Context) (model.Post, error) {
	return c.postService.GetPostById(ctx.Param("id"))
}

func (c *PostController) CreatePost(ctx *ginboot.Context, req model.Post) (model.Post, error) {
	post, err := c.postService.CreatePost(req)
	if err != nil {
		return model.Post{}, ginboot.NewApiError(400, "invalid post")
	}

	// Fire-and-forget call to another service, traced end to end
	_ = ctx.CallServiceAsync("notification-service", "/notifications/send", post)

	return post, nil
}

Batteries included

Everything a production Go service needs, wired up and ready — without giving up the Gin APIs you already know.

Ship it with Ginboot Cloud

One-click deploys, managed environments, live log streaming and telemetry dashboards — purpose-built for Ginboot services.