From e6d0b933d3a5fba2837c58ff8da5fe3f0e4f0217 Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Mon, 21 Nov 2022 06:31:21 +0800 Subject: [PATCH] `gofail --version` should exit with 0 Currently it exits with code 1, and when executing `make`, it always display an error like below, $ make GO_BUILD_FLAGS="-v" ./build.sh go.etcd.io/gofail/code go.etcd.io/gofail ./gofail --version Git SHA: dc004b5 Go Version: go1.19.2 gofail Version: 0.1.0 Go OS/Arch: linux/amd64 make: *** [gofail] Error 1 Signed-off-by: Benjamin Wang --- gofail.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gofail.go b/gofail.go index 46cf588..8f8269b 100644 --- a/gofail.go +++ b/gofail.go @@ -183,11 +183,7 @@ func main() { case "disable": xfrm = code.ToComments case "--version": - fmt.Println("Git SHA: ", GitSHA) - fmt.Println("Go Version: ", runtime.Version()) - fmt.Println("gofail Version: ", Version) - fmt.Printf("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) - os.Exit(1) + showVersion() default: fmt.Println(usageLine) os.Exit(1) @@ -217,3 +213,11 @@ func main() { } } } + +func showVersion() { + fmt.Println("Git SHA: ", GitSHA) + fmt.Println("Go Version: ", runtime.Version()) + fmt.Println("gofail Version: ", Version) + fmt.Printf("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + os.Exit(0) +}