GitHub - raeperd/kickstart.go: Minimalistic HTTP server template in Go (original) (raw)
kickstart.go
Minimalistic HTTP server template in Go that is:
- Small (less than 300 lines of code)
- Single file
- Only standard library dependencies
Not a framework, but a starting point for building HTTP services in Go. This project was first introduced in GopherCon Korea 2024, See session in this link(in Korean) and see presentation in this link(in English)
Inspired by Mat Ryer & earthboundkid and even kickstart.nvim
Features
- Graceful shutdown: Handles
SIGINTandSIGTERMsignals to shut down gracefully. - Health endpoint: Returns the server's health status including version and revision.
- OpenAPI endpoint: Serves an OpenAPI specification using
embedpackage - Debug information: Provides various debug metrics including
pprofandexpvars. - Access logging: Logs HTTP request details using
slog. - Panic recovery: Catch and log panics in HTTP handlers gracefully.
- Fully documented: Includes comments and documentation for all exported functions and types.
Getting started
- Use this template to create a new repository
- Or fork the repository and make changes to suit your needs.
Requirements
Go 1.24 or later
Suggested Dependencies
Build and run the server
- this will build the server and run it on port 8080
- Checkout Makefile for more
Endpoints
- GET /health: Returns the health of the service, including version, revision, and modification status.
- GET /openapi.yaml: Returns the OpenAPI specification of the service.
- GET /debug/pprof: Returns the pprof debug information.
- GET /debug/vars: Returns the expvars debug information.
How to
How to start a new project
- Use this template to create a new repository
- Or fork the repository and make changes to suit your needs.
- Find and replace all strings
raeperd/kickstart.gowith your repository/image name
How to remove all comments from the code
$ sed -i '' '/^//go:embed/! {/^\s//.$/d; /^\s*/**/,/*//d;}' *.go