fix: close cpu profile

Signed-off-by: guoguangwu <guoguangwug@gmail.com>
This commit is contained in:
guoguangwu 2024-04-03 13:51:10 +08:00
commit 043bd4593b

View file

@ -120,9 +120,12 @@ func New() (*Session, error) {
}
if *s.Options.CpuProfile != "" {
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
f, err := os.Create(*s.Options.CpuProfile)
if err != nil {
return nil, err
} else if err := pprof.StartCPUProfile(f); err != nil {
}
defer f.Close()
if err := pprof.StartCPUProfile(f); err != nil {
return nil, err
}
}