Skip to content

Commit

Permalink
fix: close files
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
  • Loading branch information
testwill authored and onsi committed Apr 27, 2024
1 parent 3134422 commit 32259c8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions ginkgo/generators/generate_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func moduleName(modRoot string) string {
if err != nil {
return ""
}
defer modFile.Close()

mod := make([]byte, 128)
_, err = modFile.Read(mod)
Expand Down
2 changes: 2 additions & 0 deletions ginkgo/internal/profiles_and_reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func MergeAndCleanupCoverProfiles(profiles []string, destination string) error {
if err != nil {
return err
}
defer dst.Close()
err = DumpCoverProfiles(merged, dst)
if err != nil {
return err
Expand Down Expand Up @@ -196,6 +197,7 @@ func MergeProfiles(profilePaths []string, destination string) error {
return fmt.Errorf("Could not open profile: %s\n%s", profilePath, err.Error())
}
prof, err := profile.Parse(proFile)
_ = proFile.Close()
if err != nil {
return fmt.Errorf("Could not parse profile: %s\n%s", profilePath, err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions reporters/junit_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func MergeAndCleanupJUnitReports(sources []string, dst string) ([]string, error)
continue
}
err = xml.NewDecoder(f).Decode(&report)
_ = f.Close()
if err != nil {
messages = append(messages, fmt.Sprintf("Could not decode %s:\n%s", source, err.Error()))
continue
Expand Down

0 comments on commit 32259c8

Please sign in to comment.