diff --git a/notes_unix.go b/notes_unix.go index 9a0e5c50..97345575 100644 --- a/notes_unix.go +++ b/notes_unix.go @@ -53,10 +53,13 @@ func additionalNotesAboutCommand(path string) string { } if elfFile, err := elf.Open(path); err == nil { + defer elfFile.Close() notes += fmt.Sprintf(" ELF architecture: %s (current architecture: %s)\n", elfFile.Machine, runtime.GOARCH) } else if machoFile, err := macho.Open(path); err == nil { + defer machoFile.Close() notes += fmt.Sprintf(" MachO architecture: %s (current architecture: %s)\n", machoFile.Cpu, runtime.GOARCH) } else if peFile, err := pe.Open(path); err == nil { + defer peFile.Close() machine, ok := peTypes[peFile.Machine] if !ok { machine = "unknown" diff --git a/notes_windows.go b/notes_windows.go index 15680850..7afcaf3f 100644 --- a/notes_windows.go +++ b/notes_windows.go @@ -29,10 +29,13 @@ func additionalNotesAboutCommand(path string) string { notes += fmt.Sprintf(" Mode: %s\n", stat.Mode()) if elfFile, err := elf.Open(path); err == nil { + defer elfFile.Close() notes += fmt.Sprintf(" ELF architecture: %s (current architecture: %s)\n", elfFile.Machine, runtime.GOARCH) } else if machoFile, err := macho.Open(path); err == nil { + defer machoFile.Close() notes += fmt.Sprintf(" MachO architecture: %s (current architecture: %s)\n", machoFile.Cpu, runtime.GOARCH) } else if peFile, err := pe.Open(path); err == nil { + defer peFile.Close() machine, ok := peTypes[peFile.Machine] if !ok { machine = "unknown"