Merge pull request #1087 from testwill/file_close

fix: close cpu profile
This commit is contained in:
Simone Margaritelli 2024-05-31 13:55:49 +02:00 committed by GitHub
commit ca2e257fbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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
}
}