goboot

module
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0

README

goboot

goboot

An annotation-driven, compile-time application framework for Go.

A Spring Boot–style developer experience that compiles down to plain, readable Go — no runtime reflection for DI, no classpath scanning.

Docs Go Reference Release Go 1.25 License

📖 Documentation — developer guide & annotation reference.

You annotate ordinary Go types and methods; the goboot CLI reads the annotations, builds a typed application model + dependency graph, validates it, and generates ordinary, readable Go. Dependency resolution and wiring happen at generation time — the program that ships does no reflection-based DI and no startup scanning, and every dependency is checked with go/types, never strings.

// @RestController
// @RequestMapping(path="/users")
type UserController struct{ users UserUseCase }

func NewUserController(users UserUseCase) *UserController { return &UserController{users} }

// @PostMapping(path="")
func (c *UserController) Create(ctx context.Context, req CreateRequest) (*UserResponse, error) {
    return c.users.Create(ctx, req.toInput())
}

// @Service(name="userService", implements="UserUseCase")
type UserService struct{ repo UserRepository }

func NewUserService(repo UserRepository) *UserService { return &UserService{repo} }

// @Transactional
// @Traced
// @Timed
// @Audit(action="create", resource="user")
func (s *UserService) Create(ctx context.Context, in CreateInput) (*User, error) { /* ... */ }

// @Repository(generate=true, entity="User", table="users")
type UserRepository interface {
    // @Query(`SELECT id, name FROM users WHERE id = :id`)
    FindByID(ctx context.Context, id string) (*User, error)
    // @Exec(`INSERT INTO users (id, name) VALUES (:u.ID, :u.Name)`)
    Insert(ctx context.Context, u User) error
}
goboot generate ./...

goboot emits the wiring: constructors in dependency order, HTTP routes + handler proxies (bind → validate → authorize → invoke → write), the SQL repository implementation, service proxies that apply your @Transactional/@Traced/… interceptors, typed config loaders, lifecycle, scheduled tasks, and NewApplication — all plain Go you can read and step through in a debugger.

Quickstart

# 1. install the CLI
go install github.com/zombocoder/goboot/cmd/goboot@latest

# 2. scaffold config in your module
goboot init

# 3. annotate your code (see the example above), then generate
goboot generate ./...

# 4. wire the generated app in main.go and run
go run ./cmd/server

goboot init writes a goboot.yaml; goboot generate produces internal/generated/zz_goboot_wiring.gen.go exposing NewApplication(...), RegisterRoutes(...), and buildComponents(...). Add a go:generate directive for reproducible builds:

//go:generate go run github.com/zombocoder/goboot/cmd/goboot generate ./...

Features

Area Annotations
DI @Application @Service @Component @Configuration @Nut @Primary @Named @Scope
HTTP @RestController @RequestMapping @GetMapping @PostMapping @PutMapping @PatchMapping @DeleteMapping @Response @ResponseStatus @Consumes @Produces
Errors @ControllerAdvice @ExceptionHandler (typed → response), RFC-7807 Problem
Repositories @Repository(generate=true) with @Query @Exec @Batch @Call; dialects: postgres, mysql, sqlserver, ?; driver-neutral
Interception (proxies) @Transactional @Traced @Timed @Logged @Audit @Retry @Timeout @CircuitBreaker @RateLimit @Bulkhead @Authorize @RolesAllowed
Config & lifecycle @ConfigurationProperties @PostConstruct @PreDestroy @Scheduled
Conditions & profiles @Profile @ConditionalOnProperty @ConditionalOnNut @ConditionalOnMissingNut

Core invariants: compile-time only, deterministic output (byte-identical for the same input), type-safe via go/types, and diagnostics not panics (stable GOB* codes with source positions).

Plugins & adapters

goboot is extended at compile time — plugins are Go modules linked into the CLI (no dynamic loading). List them in goboot.yaml and goboot generate self-bootstraps a plugin-aware build. Runtime adapters plug real backends into the generated code's seams.

Module Kind What it does
plugins/openapi Generator plugin Emits an OpenAPI 3 spec from your routes
plugins/oracle Dialect plugin Oracle SQL dialect (:1, :2)
plugins/lint Analyzer plugin REST convention warnings
adapters/pgx DB adapter Native PostgreSQL over jackc/pgx/v5
adapters/otel Tracing adapter @Traced → OpenTelemetry spans
adapters/prometheus Metrics adapter @Timed → Prometheus counters

Write your own with plugin.Plugin + AnnotationProvider / Analyzer / Generator / DialectProvider. Full guide: PLUGINS.md.

Editor support

A VS Code extension highlights goboot annotations inside Go doc comments and ships annotation snippets. Install the .vsix from a release or search the Marketplace for goboot Annotations.

CLI

goboot init                       # scaffold goboot.yaml
goboot generate ./...             # generate wiring (+ plugin artifacts)
goboot validate ./...             # analyze and report diagnostics, no files written
goboot graph ./... --format mermaid
goboot plugins                    # list configured vs. linked plugins
goboot clean                      # remove generated files
goboot doctor                     # environment checks
goboot version

Useful flags on generate/validate: -profile prod,staging, -property cache.enabled=true, -dialect postgres|mysql|sqlserver|question, -strict, -tags.

Status

v0.1.0 — the core framework, plugin system, three plugins, three adapters, and the VS Code extension are implemented and tested. See CLAUDE.md for an architecture overview and the package layout.

Contributing

Contributions welcome — see CONTRIBUTING.md and the Code of Conduct. Security issues: SECURITY.md.

License

Apache License 2.0.

Directories

Path Synopsis
adapters
databasesql
Package databasesql adapts Go's standard database/sql to goboot's driver-neutral db abstraction (§6.6, §27).
Package databasesql adapts Go's standard database/sql to goboot's driver-neutral db abstraction (§6.6, §27).
oidc module
pgx module
redis module
Package annotation implements goboot's `@Name(arg=value, ...)` comment annotation language (§9): the lexer and parser, the value model, and the schema registry that validates parsed annotations against their definitions.
Package annotation implements goboot's `@Name(arg=value, ...)` comment annotation language (§9): the lexer and parser, the value model, and the schema registry that validates parsed annotations against their definitions.
Package cli implements the annotation-driven compiler CLI (§43): it loads Go packages, parses annotations, validates the application, and generates type-safe wiring through the standard go/generate workflow (§44, §59).
Package cli implements the annotation-driven compiler CLI (§43): it loads Go packages, parses annotations, validates the application, and generates type-safe wiring through the standard go/generate workflow (§44, §59).
cmd
goboot command
Command goboot is the annotation-driven compiler CLI (§43).
Command goboot is the annotation-driven compiler CLI (§43).
Package compiler loads Go packages, associates annotation comments with the declarations they document, resolves type information, and validates the result against the annotation registry.
Package compiler loads Go packages, associates annotation comments with the declarations they document, resolves type information, and validates the result against the annotation registry.
generator
di
Package di generates the dependency-injection wiring for an application: a single Go source file that constructs every singleton component in dependency order and returns them (§32).
Package di generates the dependency-injection wiring for an application: a single Go source file that constructs every singleton component in dependency order and returns them (§32).
Package graph builds and analyzes the component dependency graph (§15).
Package graph builds and analyzes the component dependency graph (§15).
internal
e2e
Package model defines the intermediate application model produced by semantic analysis and consumed by the code generators (specification §38).
Package model defines the intermediate application model produced by semantic analysis and consumed by the code generators (specification §38).
Package plugin defines goboot's compile-time extension model (§46).
Package plugin defines goboot's compile-time extension model (§46).
exampleplugin
Package exampleplugin is a reference goboot plugin demonstrating every extension point (§46): it registers an annotation, contributes semantic analysis, generates an artifact, and provides a SQL dialect (as a database driver would).
Package exampleplugin is a reference goboot plugin demonstrating every extension point (§46): it registers an annotation, contributes semantic analysis, generates an artifact, and provides a SQL dialect (as a database driver would).
plugins
metrics module
openapi module
validate module
Package runtime provides the minimal reusable abstractions that goboot's generated HTTP code depends on: request binding, validation, response writing, centralized error handling, and the RFC 7807-inspired problem model (§22, §23).
Package runtime provides the minimal reusable abstractions that goboot's generated HTTP code depends on: request binding, validation, response writing, centralized error handling, and the RFC 7807-inspired problem model (§22, §23).
config
Package config loads typed configuration properties from layered sources — defaults, YAML files, and environment variables — following the precedence of §28.2.
Package config loads typed configuration properties from layered sources — defaults, YAML files, and environment variables — following the precedence of §28.2.
db
Package db defines the driver-neutral database abstractions that generated repositories depend on (§27).
Package db defines the driver-neutral database abstractions that generated repositories depend on (§27).
Package sqlgen compiles named-parameter SQL into driver-specific positional SQL (§27.4).
Package sqlgen compiles named-parameter SQL into driver-specific positional SQL (§27.4).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL