func main() { flag.Parse() if len(flag.Args()) > 0 { fmt.Fprintln(os.Stderr, "gorename: surplus arguments.") os.Exit(1) } if *helpFlag || (*offsetFlag == "" && *fromFlag == "" && *toFlag == "") { fmt.Println(rename.Usage) return } if err := rename.Main(&build.Default, *offsetFlag, *fromFlag, *toFlag); err != nil { if err != rename.ConflictError { fmt.Fprintf(os.Stderr, "gorename: %s\n", err) } os.Exit(1) } }
func main() { log.SetPrefix("gorename: ") log.SetFlags(0) flag.Parse() if len(flag.Args()) > 0 { log.Fatal("surplus arguments") } if *helpFlag || (*offsetFlag == "" && *fromFlag == "" && *toFlag == "") { fmt.Println(rename.Usage) return } if err := rename.Main(&build.Default, *offsetFlag, *fromFlag, *toFlag); err != nil { if err != rename.ConflictError { log.Fatal(err) } os.Exit(1) } }
func (i inProcRenamer) Rename(u CandidateWithUsage) { fmt.Println("Renaming", u.DisplayName) rename.Main(&build.Default, fmt.Sprintf("%s:#%d", u.Pos.Filename, u.Pos.Offset), "", unexportedName(u.Name)) time.Sleep(3 * time.Millisecond) // hack to let output buffers flush so messages stay in order }