var dryrun … var badDomains … var replaceFlag … var stderr … var writeFile … const usage … func main() { … } type canonicalName … // fiximports fixes imports in the specified packages. // Invariant: a false result implies an error was already printed. func fiximports(packages ...string) bool { … } // Invariant: false result => error already printed. func rewritePackage(client *listPackage, canonical map[string]canonicalName) bool { … } // rewriteFile reads, modifies, and writes filename, replacing all imports // of packages P in canonical by canonical[P]. // It records in used which canonical packages were imported. // used[P]=="" indicates that P was imported but its canonical path is unknown. func rewriteFile(filename string, canonical map[string]canonicalName, used map[string]bool) error { … } type listPackage … type packageError … func (e packageError) Error() string { … } // list runs 'go list' with the specified arguments and returns the // metadata for matching packages. func list(args ...string) ([]*listPackage, error) { … } var cwd … // shortPath returns an absolute or relative name for path, whatever is shorter. // Plundered from $GOROOT/src/cmd/go/build.go. func shortPath(path string) string { … }