]> Cypherpunks repositories - gostls13.git/commitdiff
gofix: add -debug flag for quicker diagnosis of internal errors
authorRobert Griesemer <gri@golang.org>
Wed, 25 Jan 2012 20:26:19 +0000 (15:26 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 25 Jan 2012 20:26:19 +0000 (15:26 -0500)
R=rsc, r
CC=golang-dev
https://golang.org/cl/5564055

src/cmd/gofix/main.go

index dfa756799a90ffaa16654101e35ea1cf2424d8d5..ca7e1a0f320dcf63be423435ef95b78c2ab25af4 100644 (file)
@@ -36,6 +36,9 @@ var allowed, force map[string]bool
 
 var doDiff = flag.Bool("diff", false, "display diffs instead of rewriting files")
 
+// enable for debugging gofix failures
+const debug = false // display incorrectly reformatted source and exit
+
 func usage() {
        fmt.Fprintf(os.Stderr, "usage: gofix [-diff] [-r fixname,...] [-force fixname,...] [path ...]\n")
        flag.PrintDefaults()
@@ -161,6 +164,11 @@ func processFile(filename string, useStdin bool) error {
                        }
                        newFile, err = parser.ParseFile(fset, filename, newSrc, parserMode)
                        if err != nil {
+                               if debug {
+                                       fmt.Printf("%s", newSrc)
+                                       report(err)
+                                       os.Exit(exitCode)
+                               }
                                return err
                        }
                }