Documentation ¶
Overview ¶
Package magehelper helps Mage projects determine a project's files and used packages.
Index ¶
- Variables
- 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 InstallTool(bin, module string) error
- func LoadDependencies(context.Context) error
- func Revive(ctx context.Context, reviveBin string, config string) error
- func ReviveDep(bin, config string) mg.Fn
- 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
- func ToolDep(bin, module string) mg.Fn
- 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 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 InstallTool ¶
InstallTool installs the given module at the given location if the file at that location either doesn't exist or doesn't have the same version as the version of the module configured in go.mod.
func LoadDependencies ¶
LoadDependencies populates the global Packages variable. It's suitable for use with mg.Deps or mg.CtxDeps.
func Revive ¶
Revive runs the given revive binary and uses the given configuration file to lint all the files in the current project. If revive is not installed, it will be installed using the version configured in go.mod.
func ReviveDep ¶
ReviveDep returns a mg.Fn object suitable for using with mg.Deps and similar. When resolved, the object will run the given revive binary and uses the given configuration file to lint all the files in the current project. If revive is not installed, it will be installed using the version configured in go.mod.
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.