if info.IsDir() {
scanDir(arg)
} else {
- scanFile(arg, info, true)
+ ok := scanFile(arg, info, true)
+ if !ok && *versionM {
+ base.SetExitStatus(1)
+ }
}
}
}
// If mustPrint is true, scanFile will report any error reading file.
// Otherwise (mustPrint is false, because scanFile is being called
// by scanDir) scanFile prints nothing for non-Go binaries.
-func scanFile(file string, info fs.FileInfo, mustPrint bool) {
+// scanFile reports whether the file is a Go binary.
+func scanFile(file string, info fs.FileInfo, mustPrint bool) bool {
if info.Mode()&fs.ModeSymlink != 0 {
// Accept file symlinks only.
i, err := os.Stat(file)
if mustPrint {
fmt.Fprintf(os.Stderr, "%s: symlink\n", file)
}
- return
+ return false
}
info = i
}
}
}
}
- return
+ return false
}
fmt.Printf("%s: %s\n", file, bi.GoVersion)
if *versionM && len(mod) > 0 {
fmt.Printf("\t%s\n", strings.ReplaceAll(mod[:len(mod)-1], "\n", "\n\t"))
}
+ return true
}