Simple Go API setup
13 June, 2025 - Categories: api
I've been experimenting with making my own API for my homelab for a while, and decided i just need to set up a simple playground where i can test things out.
From a cursory search/llm chat, it seems the common ways to get started are:
- python's Flask or FastAPI
- node.js or similar
- go
I've tried both Flask and FastAPI, they are... fine? but every time i have to deploy python i get REALLY annoyed with the whole ecosystem, the massive overhead of just making sure your python actually runs correctly on different machines, by different users. UV solves a lot of it (i really need to make a blog post on it soon) but i just couldn't be bothered, it feels like 3 layers of overhead for a simple API is just asking to break in fun ways.
I won't even start talking about the javascript ecosystem / npm, i'm just not gonna touch it.
so we're left with go for now - from what i see, this is pretty much purpose-built for APIs and servers and the like, so definitely worth checking out. i also enjoy using several tools written in go in my homelab, they are usually made with the admin in mind, so a simple single-binary setup makes running it very easy, and i find many of them do use sane defaults and don't randomly break things on updates - not sure if i'm just choosing lucky stuff or if the community just knows a lot of these pain points and does it's best to avoid them.
Anyway - the current setup: a go binary that uses the http module to listen and respond to requests (behind a caddy reverse proxy, so anything looking for /api/ gets routed to go, anything else is just html files in a directory) the binary watches itself - if i upload a new binary, it notices and immediately restarts itself, very convenient
some simple html, css and vanilla javascript to call the apis and see results
The whole folder is on my server, but i mount it locally so i can use my tools here and any changes are immediately reflected. it is working very well so far.
also - claude code is pretty damn good at this, easily making new endpoints and test pages.