Skip to content

Commit 9d9098f

Browse files
Sandor Szücsccojocar
authored andcommitted
print version string (#317)
Signed-off-by: Sandor Szücs <[email protected]>
1 parent ee80733 commit 9d9098f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/gosec/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ var (
104104
// scan tests files
105105
flagScanTests = flag.Bool("tests", false, "Scan tests files")
106106

107+
// print version and quit with exit code 0
108+
flagVersion = flag.Bool("version", false, "Print version and quit with exit code 0")
109+
107110
logger *log.Logger
108111
)
109112

@@ -219,6 +222,11 @@ func main() {
219222
// Parse command line arguments
220223
flag.Parse()
221224

225+
if *flagVersion {
226+
fmt.Printf("Version: %s\nGit tag: %s\nBuild date: %s\n", Version, GitTag, BuildDate)
227+
os.Exit(0)
228+
}
229+
222230
// Ensure at least one file was specified
223231
if flag.NArg() == 0 {
224232
fmt.Fprintf(os.Stderr, "\nError: FILE [FILE...] or './...' expected\n") // #nosec

0 commit comments

Comments
 (0)