net/http vs Gin vs Chi

When You Don't Need a Framework

Web
Use net/http for zero-dependency services, chi for lightweight routing, and avoid heavy frameworks like Gin unless specific features are required.

Use the standard library net/http for simple services and chi for lightweight routing; skip frameworks like Gin unless you need heavy middleware or rapid prototyping features. The standard library provides zero-dependency performance, while chi adds a clean router on top of it without the overhead of full frameworks.

package main

import (
	"net/http"
	"github.com/go-chi/chi/v5"
)

func main() {
	// Standard library only (zero deps)
	// http.HandleFunc("/", handler)
	// http.ListenAndServe(":8080", nil)

	// With Chi (lightweight routing)
	r := chi.NewMux()
	r.Get("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("Hello"))
	})
	http.ListenAndServe(":8080", r)
}