package main import ( "os" "runtime" "runtime/pprof" "git.eeqj.de/sneak/vaultik/internal/cli" ) func main() { // CPU profiling: set VAULTIK_CPUPROFILE=/path/to/cpu.prof if cpuProfile := os.Getenv("VAULTIK_CPUPROFILE"); cpuProfile != "" { f, err := os.Create(cpuProfile) if err != nil { panic("could not create CPU profile: " + err.Error()) } defer func() { _ = f.Close() }() if err := pprof.StartCPUProfile(f); err != nil { panic("could not start CPU profile: " + err.Error()) } defer pprof.StopCPUProfile() } // Memory profiling: set VAULTIK_MEMPROFILE=/path/to/mem.prof if memProfile := os.Getenv("VAULTIK_MEMPROFILE"); memProfile != "" { defer func() { f, err := os.Create(memProfile) if err != nil { panic("could not create memory profile: " + err.Error()) } defer func() { _ = f.Close() }() runtime.GC() // get up-to-date statistics if err := pprof.WriteHeapProfile(f); err != nil { panic("could not write memory profile: " + err.Error()) } }() } cli.CLIEntry() }