mirror of
https://github.com/golang/go
synced 2024-11-23 18:30:06 -07:00
cmd/go: set exit status for failing "go generate" run.
LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/154360048
This commit is contained in:
parent
82a0188c88
commit
c57cb7867e
@ -169,6 +169,7 @@ func (g *Generator) run() (ok bool) {
|
|||||||
if e != stop {
|
if e != stop {
|
||||||
panic(e)
|
panic(e)
|
||||||
}
|
}
|
||||||
|
setExitStatus(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
g.dir, g.file = filepath.Split(g.path)
|
g.dir, g.file = filepath.Split(g.path)
|
||||||
@ -267,7 +268,8 @@ Words:
|
|||||||
var stop = fmt.Errorf("error in generation")
|
var stop = fmt.Errorf("error in generation")
|
||||||
|
|
||||||
// errorf logs an error message prefixed with the file and line number.
|
// errorf logs an error message prefixed with the file and line number.
|
||||||
// It then exits the program because generation stops at the first error.
|
// It then exits the program (with exit status 1) because generation stops
|
||||||
|
// at the first error.
|
||||||
func (g *Generator) errorf(format string, args ...interface{}) {
|
func (g *Generator) errorf(format string, args ...interface{}) {
|
||||||
fmt.Fprintf(os.Stderr, "%s:%d: %s\n", shortPath(g.path), g.lineNum,
|
fmt.Fprintf(os.Stderr, "%s:%d: %s\n", shortPath(g.path), g.lineNum,
|
||||||
fmt.Sprintf(format, args...))
|
fmt.Sprintf(format, args...))
|
||||||
|
Loading…
Reference in New Issue
Block a user