//go:build !debug package main import ( "context" "docker-updater/constant" "log/slog" "os" "runtime" "runtime/debug" "strings" ) func main() { ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() logger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) slog.SetDefault(logger) defer func() { if r := recover(); r != nil { if info, ok := debug.ReadBuildInfo(); ok { var settings []string for _, setting := range info.Settings { settings = append(settings, setting.Key+":"+setting.Value) } slog.Error("a panic occured", "err", r, "os", runtime.GOOS, "arch", runtime.GOARCH, "num_cpu", runtime.NumCPU(), "num_cgo_call", runtime.NumCgoCall(), "num_goroutine", runtime.NumGoroutine(), "go_version", info.GoVersion, "build_settings", strings.Join(settings, ", "), ) } else { slog.Error("a panic occured, no build info available", "err", r, "os", runtime.GOOS, "arch", runtime.GOARCH, "num_cpu", runtime.NumCPU(), "num_cgo_call", runtime.NumCgoCall(), "num_goroutine", runtime.NumGoroutine(), ) } } }() debug.SetTraceback("none") slog.Info("docker-updater", "version", constant.ProgramVersion().String(), "os", runtime.GOOS, "arch", runtime.GOARCH) os.Exit(run(ctx, false)) }