Documentation
¶
Index ¶
- Constants
- Variables
- func Build(pkg string, out string) (string, error)
- func ChangePackage(pkgName, desiredPkgName string) error
- func CopyPackageToCache(pkg *packages.Package, cacheDir string) (string, error)
- func FindPackage(pkg string) (*packages.Package, error)
- func GenerateSymbolsForModels(symbolNames []string, out string) ([]string, error)
- func LoadSymbols(pluginPath string, symbols []string) ([]interface{}, error)
- type Loader
Constants ¶
const DefaultCache = ".mirror"
Variables ¶
var ( ErrFindPackageFailed = errors.New("An error occurred when loading plugin") ErrCopyingToCacheFailed = errors.New("Failed to copy package to the cache") ErrSymbolGenerationFailed = errors.New("Failed to generate symbols") ErrBuildFailed = errors.New("Failed to build the plugin") ErrSymbolLoadFailed = errors.New("Failed to load symbols from the plugin") )
Functions ¶
func Build ¶
Build builds the given package into plugin and saves it in current path under a random name .so, returning the name to the caller
func ChangePackage ¶
ChangePackage changes the `package X` line of each file in the targeted package, changing its name to the desiredPkgName, running the `run` function and changing it back to the default
func CopyPackageToCache ¶
CopyPackageToCache copies a given package into a given cache dir returning the cache dir subdirectory into which the package was copied
func FindPackage ¶
FindPackage returns names of go files in the targeted package
func GenerateSymbolsForModels ¶
GenerateSymbolsForModels generates symbols for all models, mutates the input symbols to be compatible with newly created symbols and writes a new file with these generated symbols
func LoadSymbols ¶
LoadSymbols accepts a plugin path and returns all symbols that were found in the given plugin. If * is provided as only value in `symbols`, all symbols from the given plugin will be returned
Types ¶
type Loader ¶
type Loader struct {
// TargetPath is a relative path to the plugin that should be built
TargetPath string
// PreserveCache determines if the copied cached files should be preserved
// at the end of the lifecycle
PreserveCache bool
// GenerateSymbols automatically generates symbols for desired types,
// e.g. type User struct {} will have his var XUser User generated
// in case it is passed into symbolNames for Load function
GenerateSymbols bool
// CacheDir can be used to override the default setting of the cache directory
// if not set, this will default to the DefaultCache
CacheDir string
}
Loader encapsulates full lifecycle of a plugin