Full-stack framework for Go
Laravel's developer experience, built on the Go standard library.
Golar generates API, Web and Full Stack projects and gives them routing, validation, an ORM, authentication, sessions and mail, while net/http handlers, database/sql and standard middleware keep working as usual.
go install github.com/dayanchm/golar/cmd/golar@v0.5.1
golar new blog --template fullstack --frontend react \
--database sqlite --auth session
cd blog && go mod tidy && golar migrate && golar serve
What's included
CLI and scaffolding
golar new creates API, Web or Full Stack projects with React, Vue or Svelte, a database, authentication and Docker.
Routing
Groups, route priority, error-returning handlers and a graceful server with sensible timeouts.
Request context
JSON, forms and uploads with body limits, secure cookies, templates, redirects and downloads.
Middleware
Request IDs, logging, recovery, CORS, security headers, body limits, timeouts and gzip.
Validation
Struct-tag rules, custom messages and database rules, answered as JSON 422.
Database and ORM
SQLite, PostgreSQL and MySQL with migrations, a query builder and a generics-based ORM.
Authentication
Argon2id, session and token guards, CSRF, rate limiting, gates, policies and roles.
SMTP with STARTTLS, a log driver, a test fake and ready-made reset and verification emails.
Handlers that read like the problem
Handlers return errors. The default error handler turns validation failures into 422 JSON, oversized bodies into 413 and everything unexpected into a logged 500, so the happy path stays short.
- Plain
func(http.Handler) http.Handlermiddleware - Session IDs and tokens stored as SHA-256 hashes
- Tested against real SQLite, PostgreSQL and MySQL
type CreatePost struct {
Title string `json:"title" validate:"required,max=120"`
Body string `json:"body" validate:"required"`
}
app := golar.New()
app.Use(middleware.RequestID(), middleware.Logger(), middleware.Recovery())
app.Post("/posts", func(c *golar.Context) error {
var in CreatePost
if err := c.Validate(&in); err != nil {
return err // 422 with field errors
}
post := models.Post{Title: in.Title, Body: in.Body}
if err := orm.Create(c.Context(), db, &post); err != nil {
return err
}
return c.JSON(http.StatusCreated, post)
})