rewriteImport rewrites any import of path oldPath to path newPath.
(f *ast.File, oldPath, newPath string)
| 681 | |
| 682 | // rewriteImport rewrites any import of path oldPath to path newPath. |
| 683 | func 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 | |
| 696 | func usesImport(f *ast.File, path string) (used bool) { |
| 697 | spec := importSpec(f, path) |