Skip to content

Commit 930b2bf

Browse files
authored
additional notes: ensure to close files (#241)
1 parent a4df04d commit 930b2bf

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

notes_unix.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ func additionalNotesAboutCommand(path string) string {
5353
}
5454

5555
if elfFile, err := elf.Open(path); err == nil {
56+
defer elfFile.Close()
5657
notes += fmt.Sprintf(" ELF architecture: %s (current architecture: %s)\n", elfFile.Machine, runtime.GOARCH)
5758
} else if machoFile, err := macho.Open(path); err == nil {
59+
defer machoFile.Close()
5860
notes += fmt.Sprintf(" MachO architecture: %s (current architecture: %s)\n", machoFile.Cpu, runtime.GOARCH)
5961
} else if peFile, err := pe.Open(path); err == nil {
62+
defer peFile.Close()
6063
machine, ok := peTypes[peFile.Machine]
6164
if !ok {
6265
machine = "unknown"

notes_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ func additionalNotesAboutCommand(path string) string {
2929
notes += fmt.Sprintf(" Mode: %s\n", stat.Mode())
3030

3131
if elfFile, err := elf.Open(path); err == nil {
32+
defer elfFile.Close()
3233
notes += fmt.Sprintf(" ELF architecture: %s (current architecture: %s)\n", elfFile.Machine, runtime.GOARCH)
3334
} else if machoFile, err := macho.Open(path); err == nil {
35+
defer machoFile.Close()
3436
notes += fmt.Sprintf(" MachO architecture: %s (current architecture: %s)\n", machoFile.Cpu, runtime.GOARCH)
3537
} else if peFile, err := pe.Open(path); err == nil {
38+
defer peFile.Close()
3639
machine, ok := peTypes[peFile.Machine]
3740
if !ok {
3841
machine = "unknown"

0 commit comments

Comments
 (0)