Go 1.21 introduces built-in min and max functions, a structured logging package log/slog, and the GODEBUG environment variable for controlling runtime behavior. Use min and max to replace verbose conditional logic, log/slog for structured logs, and GODEBUG to manage compatibility settings like panicnil.
package main
import (
"fmt"
"log/slog"
)
func main() {
// Built-in min/max
fmt.Println(min(1, 2)) // 1
fmt.Println(max(3, 4)) // 4
// Structured logging
slog.Info("Starting server", "port", 8080)
// GODEBUG example (set in environment before running)
// GODEBUG=panicnil=1 go run main.go
}