cmd/govulncheck: exit with a non-zero code if there are vulns

Updates golang/go#51590

Cherry-picked: https://go-review.googlesource.com/c/exp/+/393415

Change-Id: Ieffa62d753c0db79ec576368822831ab76cbdc6f
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/395239
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/cmd/govulncheck/main.go b/cmd/govulncheck/main.go
index 4b09e0b..308b081 100644
--- a/cmd/govulncheck/main.go
+++ b/cmd/govulncheck/main.go
@@ -123,7 +123,12 @@
 	} else {
 		writeText(r, pkgs)
 	}
-
+	exitCode := 0
+	// Following go vet, fail with 3 if there are findings (in this case, vulns).
+	if len(r.Vulns) > 0 {
+		exitCode = 3
+	}
+	os.Exit(exitCode)
 }
 
 func writeJSON(r *vulncheck.Result) {