Documentation ¶
Overview ¶
Package magehelper helps Mage projects determine a project's files and used packages.
Index ¶
- Variables
- func BasePackage() (string, error)
- func Build(ctx context.Context, exe string, tags []string) error
- func BuildTest(ctx context.Context, pkg string, tags ...string) error
- func BuildTestDep(pkg string, tags ...string) mg.Fn
- func BuildTests(ctx context.Context, tags ...string) error
- func BuildTestsDep(tags ...string) mg.Fn
- func GetDependencies(baseMod string, files func(pkg Package) []string, ...) (result []string)
- func LoadDependencies(context.Context) error
- func RunTest(ctx context.Context, pkg string, tags ...string) error
- func RunTestDep(pkg string, tags ...string) mg.Fn
- func Test(ctx context.Context, tags ...string) error
- type Package
Constants ¶
This section is empty.
Variables ¶
var Packages = map[string]Package{}
Packages holds the results of the LoadDependencies function. This variable is only valid after that function runs. Use mg.Deps or similar to make sure dependencies are loaded before referring to this variable.
Functions ¶
func BasePackage ¶
BasePackage returns the full name of the package being tested. It reads go.mod, which means this is intended to be used on tests being run in situ from the project directory, not tests compiled and copied elsewhere to run.
func Build ¶
Build builds the current package with the given tags and writes the result to the given binary location.
func BuildTestDep ¶
BuildTestDep returns a mg.Fn that will build the tests for the given package, subject to any given build tags.
func BuildTests ¶
BuildTests build all the tests.
func BuildTestsDep ¶
BuildTestsDep returns a mg.Fn that will build all the tests using the given build tags.
func GetDependencies ¶
func GetDependencies( baseMod string, files func(pkg Package) []string, imports func(pkg Package) []string, ) (result []string)
GetDependencies returns a list of files that the given base module depends on. The files callback should return a list of source files for a given package, and the imports callback should return a list of modules that the package imports. Use functions like Package.SourceFiles and Package.SourceImportPackages.
func LoadDependencies ¶
LoadDependencies populates the global Packages variable. It's suitable for use with mg.Deps or mg.CtxDeps.
func RunTestDep ¶
RunTestDep returns a mg.Fn that will run the tests for the given package, subject to the given build tags.
Types ¶
type Package ¶
type Package struct { Dir string ImportPath string Name string Target string GoFiles []string IgnoredGoFiles []string TestGoFiles []string XTestGoFiles []string EmbedFiles []string TestEmbedFiles []string XTestEmbedFiles []string Imports []string TestImports []string XTestImports []string }
Package represents the output from go list -json. It's based on the internal package defined in cmd/go and on go/build.Package.
func (Package) IndirectGoFiles ¶
IndirectGoFiles returns the files that aren't automatically selected as being part of the package proper. Contract with github.com/mgechev/dots.Resolve, which will return the files that are direct members of the package, but it will not include other files from the same directory that belong to different packages, such as main or the _test package.
func (Package) SourceFiles ¶
SourceFiles returns the files that contribute to an ordinary build; these are the dependencies to check to determine whether the package needs to be rebuilt.
func (Package) SourceImportPackages ¶
SourceImportPackages returns the names of other packages imported by the package.
func (Package) TestFiles ¶
TestFiles returns the files that contribute to the tests; these are the dependencies to check to determine whether the tests need to be rebuilt.
func (Package) TestImportPackages ¶
TestImportPackages returns the names of other packages imported by this package's tests.
Directories ¶
Path | Synopsis |
---|---|
Package tools offers Mage dependencies and commands to help install tools for use during a build, such as linters and code generators.
|
Package tools offers Mage dependencies and commands to help install tools for use during a build, such as linters and code generators. |