]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: add -panic flag to gotype command for debugging
authorRobert Griesemer <gri@golang.org>
Thu, 22 Feb 2018 18:15:42 +0000 (10:15 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 22 Feb 2018 21:46:19 +0000 (21:46 +0000)
Setting -panic will cause gotype to panic with the first reported
error, producing a stack trace for debugging.

For #23914.

Change-Id: I40c41cf10aa13d1dd9a099f727ef4201802de13a
Reviewed-on: https://go-review.googlesource.com/96375
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/go/types/gotype.go

index 2efb4c0ac9ef48772891bf423d3b51a77fbfeb35..cde373f3556c775d443d82c42a2fe8c0af32f339 100644 (file)
@@ -53,6 +53,8 @@ Flags controlling additional output:
                print parse trace (forces -seq)
        -comments
                parse comments (ignored unless -ast or -trace is provided)
+       -panic
+               panic on first error
 
 Examples:
 
@@ -105,6 +107,7 @@ var (
        printAST      = flag.Bool("ast", false, "print AST (forces -seq)")
        printTrace    = flag.Bool("trace", false, "print parse trace (forces -seq)")
        parseComments = flag.Bool("comments", false, "parse comments (ignored unless -ast or -trace is provided)")
+       panicOnError  = flag.Bool("panic", false, "panic on first error")
 )
 
 var (
@@ -164,6 +167,9 @@ func usage() {
 }
 
 func report(err error) {
+       if *panicOnError {
+               panic(err)
+       }
        scanner.PrintError(os.Stderr, err)
        if list, ok := err.(scanner.ErrorList); ok {
                errorCount += len(list)