Go 1.22 introduces native range loops over integers and enhanced ServeMux pattern matching for cleaner HTTP routing. Use the new integer range syntax to iterate from 0 to n-1 without explicit counters, and leverage ServeMux's wildcard and prefix matching for flexible endpoint definitions.
// Range over integers (0 to 9)
for i := range 10 {
fmt.Println(i)
}
// ServeMux with wildcard and prefix matching
mux := http.NewServeMux()
mux.HandleFunc("/api/v{version}", handleAPI)
mux.HandleFunc("/static/", handleStatic)