Blog

Building a Spring Boot CLI in Go: what I learned

I built SpringCLI, a command-line tool in Go to scaffold Spring Boot projects — inspired by the Symfony CLI. Here's what I learned along the way.

I spent the last few months building SpringCLI — a Go CLI tool that scaffolds Spring Boot REST API projects. Here’s an honest look at what I built and what surprised me.

The motivation

Anyone who’s used the Symfony CLI knows how pleasant it makes project creation. Spring Boot has start.spring.io, but no real CLI equivalent. I wanted to fix that.

Why Go for a CLI?

Go compiles to a single static binary — no runtime, no dependency manager needed on the target machine. For a CLI tool that developers install globally, that’s a huge win.

// Simple, readable, fast
cmd := &cobra.Command{
    Use:   "new [name]",
    Short: "Scaffold a new Spring Boot project",
    Run: func(cmd *cobra.Command, args []string) {
        // ...
    },
}

I used Cobra for the CLI framework — it’s the standard in the Go ecosystem.

The hardest part: generating Java/Spring structures

The real challenge was generating valid Spring Boot project structures. A Spring Boot project has specific conventions — package names, annotation placement, directory layout.

I ended up templating the files with Go’s text/template, which worked well once I got the hang of it.

What I’d do differently

  • Add tests earlier — I refactored the project structure twice because I had no safety net
  • Design the config format first — the CLI flags evolved organically, which created inconsistencies

What’s next

The first version is usable for basic scaffolding. Next up: endpoint generation and Docker Compose setup.

If you want to try it or contribute, the repo is open — feedback welcome.