]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: set exit status to non zero for all cases
authorFatih Arslan <ftharsln@gmail.com>
Sat, 27 May 2017 23:42:34 +0000 (02:42 +0300)
committerRob Pike <r@golang.org>
Sun, 28 May 2017 10:23:38 +0000 (10:23 +0000)
Vet returns with a nonzero exit for all possible messages in the
buildtag check. However for this file:

    //+buildlinux

    package main

vet returns a zero exit status:

    $ go vet main.go
    demo.go:1: possible malformed +build comment
    $ echo $?
    0

This CL sets the exit status to non zero for the remaining messages in
the buildtag check.

Change-Id: Ia2c35ebc3ec5ac311d2a0295b5b9fdd997a85726
Reviewed-on: https://go-review.googlesource.com/44371
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/buildtag.go

index ccf764ef89b4b57ee0a530e971ae596cbd5bdec2..5fa08b62d7eb22d6b6f0cd7a25d2387786d7c06f 100644 (file)
@@ -52,6 +52,7 @@ func checkBuildTag(name string, data []byte) {
                        if !bytes.Equal(fields[0], plusBuild) {
                                // Comment is something like +buildasdf not +build.
                                fmt.Fprintf(os.Stderr, "%s:%d: possible malformed +build comment\n", name, i+1)
+                               setExit(1)
                                continue
                        }
                        if i >= cutoff {
@@ -85,6 +86,7 @@ func checkBuildTag(name string, data []byte) {
                // Comment with +build but not at beginning.
                if bytes.Contains(line, plusBuild) && i < cutoff {
                        fmt.Fprintf(os.Stderr, "%s:%d: possible malformed +build comment\n", name, i+1)
+                       setExit(1)
                        continue
                }
        }