type fix … var fixes … func register(f fix) { … } // walk traverses the AST x, calling visit(y) for each node y in the tree but // also with a pointer to each ast.Expr, ast.Stmt, and *ast.BlockStmt, // in a bottom-up traversal. func walk(x any, visit func(any)) { … } func nop(any) { … } // walkBeforeAfter is like walk but calls before(x) before traversing // x's children and after(x) afterward. func walkBeforeAfter(x any, before, after func(any)) { … } // imports reports whether f imports path. func imports(f *ast.File, path string) bool { … } // importSpec returns the import spec if f imports path, // or nil otherwise. func importSpec(f *ast.File, path string) *ast.ImportSpec { … } // importPath returns the unquoted import path of s, // or "" if the path is not properly quoted. func importPath(s *ast.ImportSpec) string { … } // declImports reports whether gen contains an import of path. func declImports(gen *ast.GenDecl, path string) bool { … } // isTopName reports whether n is a top-level unresolved identifier with the given name. func isTopName(n ast.Expr, name string) bool { … } // renameTop renames all references to the top-level name old. // It reports whether it makes any changes. func renameTop(f *ast.File, old, new string) bool { … } // matchLen returns the length of the longest prefix shared by x and y. func matchLen(x, y string) int { … } // addImport adds the import path to the file f, if absent. func addImport(f *ast.File, ipath string) (added bool) { … } // deleteImport deletes the import path from the file f, if present. func deleteImport(f *ast.File, path string) (deleted bool) { … } // rewriteImport rewrites any import of path oldPath to path newPath. func rewriteImport(f *ast.File, oldPath, newPath string) (rewrote bool) { … }