this module provides some basic utilities for you to do code migration on large code base written in golang.
NOTE: I found that using dst/ast module to parse src code with all dependencies can be very time-consuming and error-prone because there are underscore-imports and dot-imports. So I often comment out the import block in the preprocess phase and uncomment that back in the postprocess phase.
$ go get -u github.com/ZhengHe-MD/gorefactor
ParseSrcFile(filename string) (df *dst.File, err error)
ParseSrcFileFromBytes(src []byte) (df *dst.File, err error)
FprintFile(out io.Writer, df *dst.File) error
HasStmtInsideFuncBody(df *dst.File, funcName string, stmt dst.Stmt) (ret bool)
DeleteStmtFromFuncBody(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)
AddStmtToFuncBody(df *dst.File, funcName string, stmt dst.Stmt, pos int) (modified bool)
AddStmtToFuncBodyStart(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)
AddStmtToFuncBodyEnd(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)
AddStmtToFuncBodyBefore(df *dst.File, funcName string, stmt, refStmt dst.Stmt) (modified bool)
AddStmtToFuncBodyAfter(df *dst.File, funcName string, stmt, refStmt dst.Stmt) (modified bool)
AddStmtToFuncLitBody(df *dst.File, scope Scope, stmt dst.Stmt, pos int) (modified bool)
AddFieldToFuncLitParams(df *dst.File, scope Scope, field *dst.Field, pos int) (modified bool)
HasArgInCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr) (ret bool)
DeleteArgFromCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr) (modified bool)
AddArgToCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr, pos int) (modified bool)
SetMethodOnReceiver(df *dst.File, scope Scope, receiver, oldMethod, newMethod string) (modified bool)
HasFieldInFuncDeclParams(df *dst.File, funcName string, field *dst.Field) (ret bool)
DeleteFieldFromFuncDeclParams(df *dst.File, funcName string, field *dst.Field) (modified bool)
AddFieldToFuncDeclParams(df *dst.File, funcName string, field *dst.Field, pos int) (modified bool)
-[x] support scope