Documentation ¶
Overview ¶
Package importpaths implements import path rewriting credit: https://gist.github.com/jackspirou/61ce33574e9f411b8b4a
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = errors.New("skip import")
ErrSkip is used to signal that an import should be skipped
Functions ¶
func Rewrite ¶
func Rewrite(dir string, replace ReplaceFunc) error
Rewrite takes a directory path and a function for replacing imports paths Note: underscore-prefix, dot-prefix, vendor, and submodule directories are skipped.
func RewriteFile ¶
func RewriteFile(name string, replace ReplaceFunc) error
RewriteFile rewrites import statments in the named file according to the rules supplied by the map of strings.
func RewriteModule ¶ added in v0.8.0
func RewriteModule(dir string, opt RewriteModuleOptions) error
RewriteModule rewrites imports of a specific module to a new version or prefix. If a package directory is provided, only imports of that package will be rewritten.
Types ¶
type ReplaceFunc ¶
ReplaceFunc is called with every import path and returns the replacement path if the second return parameter is false, the replacement doesn't happen