From c4a685316bb478e82cda6e8017689f4758ebfff4 Mon Sep 17 00:00:00 2001 From: Kaushal Subedi Date: Mon, 26 Oct 2015 20:49:11 -0600 Subject: changed the way imports are replaced on AST --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index c757961..cc1c227 100644 --- a/main.go +++ b/main.go @@ -155,7 +155,7 @@ func ProcessFileAST(filePath string, from string, to string) { for _, mPackage := range imports { for _, mImport := range mPackage { // Since astutil returns the path string with quotes, remove those - importString := strings.Replace(mImport.Path.Value, "\"", "", -1) + importString := mImport.Path.Value // If the path matches the oldpath, replace it with the new one if strings.Contains(importString, from) { @@ -163,7 +163,7 @@ func ProcessFileAST(filePath string, from string, to string) { numChanges++ // Join the path of the import package with the remainder from the old one after removing the old import package - replacePackage := path.Join(to, strings.Replace(importString, from, "", -1)) + replacePackage := strings.Replace(importString, from, to, -1) fmt.Println(red + "Updating import " + importString + " from file " + reset + white + filePath + reset + red + " to " + reset + white + replacePackage + reset) -- cgit v1.2.3