MCPcopy Create free account
hub / github.com/decomp/decomp / rewriteImport

Function rewriteImport

cmd/go-post/fix.go:683–694  ·  view source on GitHub ↗

rewriteImport rewrites any import of path oldPath to path newPath.

(f *ast.File, oldPath, newPath string)

Source from the content-addressed store, hash-verified

681
682// rewriteImport rewrites any import of path oldPath to path newPath.
683func rewriteImport(f *ast.File, oldPath, newPath string) (rewrote bool) {
684 for _, imp := range f.Imports {
685 if importPath(imp) == oldPath {
686 rewrote = true
687 // record old End, because the default is to compute
688 // it using the length of imp.Path.Value.
689 imp.EndPos = imp.End()
690 imp.Path.Value = strconv.Quote(newPath)
691 }
692 }
693 return
694}
695
696func usesImport(f *ast.File, path string) (used bool) {
697 spec := importSpec(f, path)

Callers 1

rewriteImportFnFunction · 0.85

Calls 1

importPathFunction · 0.85

Tested by 1

rewriteImportFnFunction · 0.68