importpaths

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package importpaths implements import path rewriting credit: https://gist.github.com/jackspirou/61ce33574e9f411b8b4a

Index

Constants

This section is empty.

Variables

View Source
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.

Types

type ReplaceFunc

type ReplaceFunc func(pos token.Position, path string) (string, error)

ReplaceFunc is called with every import path and returns the replacement path if the second return parameter is false, the replacement doesn't happen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL