Closed uzaxirr closed 1 year ago
Calling os.Close on an io.Closer may return an error, and ignoring the same might result in a data loss.
os.Close
io.Closer
There are 3 occurrences of this issue in the repository.
See all occurrences on DeepSource → deepsource.io/gh/ZeStream/zestream-server/issue/GO-S2307/occurrences/
package main import ( "fmt" "os" ) func foo() error { f, err := os.Create("/tmp/test.txt") if err != nil { return err } defer f.Close() return fmt.Fprint(f, "Hello World") }
package main import ( "fmt" "os" ) func foo() error { f, err := os.Create("/tmp/test.txt") if err != nil { return err } err = fmt.Fprint(f, "Hello World") if err != nil { return err } return f.Close() }
package main import ( "fmt" "os" ) func foo() error { f, err := os.Create("/tmp/test.txt") if err != nil { return err } defer f.Close() err = fmt.Fprint(f, "Hello World") if err != nil { return err } return f.Sync() }
I am working on this @uzaxirr @abhishekraj272. I have recently started learning Go and using this repo to learn simultaneously!
Description
Calling
os.Close
on anio.Closer
may return an error, and ignoring the same might result in a data loss.Occurrences
There are 3 occurrences of this issue in the repository.
See all occurrences on DeepSource → deepsource.io/gh/ZeStream/zestream-server/issue/GO-S2307/occurrences/
Suggestions
Bad Practice
Recommend