diff options
| author | Teddy Wing | 2023-05-18 13:16:49 +0200 |
|---|---|---|
| committer | Teddy Wing | 2023-05-18 13:16:49 +0200 |
| commit | 4859ae4083e5035cc75527423fe5be69a1201b64 (patch) | |
| tree | 76c80d5dc84d54ad2a3c2fe70a8efb23d87f0d40 /cmd | |
| parent | 3fb25b9de7f5673fe2af04606c7b35bb53f1f2bf (diff) | |
| download | gocapturedrefrace-4859ae4083e5035cc75527423fe5be69a1201b64.tar.bz2 | |
gocapturedrefrace/main: Add version command line argument
I don't need to use the `flags` package here for a single boolean
option. Previously I had tried with `flags` but it conflicted with the
flags defined by `analyzer.Analyzer`.
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/gocapturedrefrace/main.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/gocapturedrefrace/main.go b/cmd/gocapturedrefrace/main.go index 60c7838..5a8970b 100644 --- a/cmd/gocapturedrefrace/main.go +++ b/cmd/gocapturedrefrace/main.go @@ -16,14 +16,25 @@ // along with Gocapturedrefrace. If not, see // <https://www.gnu.org/licenses/>. - package main import ( + "os" + "golang.org/x/tools/go/analysis/singlechecker" "gopkg.teddywing.com/capturedrefrace" ) +var version = "0.0.1" + func main() { + if len(os.Args) > 1 && + (os.Args[1] == "-V" || + os.Args[1] == "--version") { + + println(version) + os.Exit(0) + } + singlechecker.Main(capturedrefrace.Analyzer) } |
