Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Rewrite ¶
func Rewrite( buildCtx *build.Context, srcDir string, paths []string, getApplyFuncs func(pkg *Package) (pre, post apply.ApplyFunc), ) ([]string, error)
Rewrite reads, parses and type checks the Go code in all the given packages, and traverses the syntax tree of each file, calling pre and post for each node as described in the apply package. Any changes made to the syntax tree will be written to the respective file.
Rewrite returns a slice holding the names of all the packages that have been changed.
Types ¶
type Package ¶
type Package struct {
Prog *loader.Program
*loader.PackageInfo
// contains filtered or unexported fields
}
func (*Package) IsPkgDot ¶
isPkgDot reports whether t is a selector expression of the form x.name where x refers to the package with the given import path.
func (*Package) IsPkgName ¶
IsPkgName reports whether t refers to a package with the given import path.
func (*Package) PackageIdent ¶
PackageName returns a new identifier that refers to the given import path. Rewrite will ensure that the named package will be imported by the file being rewritten. The identifier argument holds the preferred identifier for the package, which will be used if the package doesn't already a local identifier. If identifier is empty, a suitable name will be chosen automatically.