mage: github.com/magefile/mage/mg Index | Files

package mg

import "github.com/magefile/mage/mg"

Index

Package Files

deps.go errors.go runtime.go

Constants

const CacheEnv = "MAGEFILE_CACHE"

CacheEnv is the environment variable that users may set to change the location where mage stores its compiled binaries.

const DebugEnv = "MAGEFILE_DEBUG"

DebugEnv is the environment variable that indicates the user requested debug mode when running mage.

const GoCmdEnv = "MAGEFILE_GOCMD"

GoCmdEnv is the environment variable that indicates the go binary the user desires to utilize for Magefile compilation.

const IgnoreDefaultEnv = "MAGEFILE_IGNOREDEFAULT"

IgnoreDefaultEnv is the environment variable that indicates the user requested to ignore the default target specified in the magefile.

const VerboseEnv = "MAGEFILE_VERBOSE"

VerboseEnv is the environment variable that indicates the user requested verbose mode when running a magefile.

func CacheDir Uses

func CacheDir() string

CacheDir returns the directory where mage caches compiled binaries. It defaults to $HOME/.magefile, but may be overridden by the MAGEFILE_CACHE environment variable.

func CtxDeps Uses

func CtxDeps(ctx context.Context, fns ...interface{})

CtxDeps runs the given functions as dependencies of the calling function. Dependencies must only be of type:

func()
func() error
func(context.Context)
func(context.Context) error

Or a similar method on a mg.Namespace type.

The function calling Deps is guaranteed that all dependent functions will be run exactly once when Deps returns. Dependent functions may in turn declare their own dependencies using Deps. Each dependency is run in their own goroutines. Each function is given the context provided if the function prototype allows for it.

func Debug Uses

func Debug() bool

Debug reports whether a magefile was run with the verbose flag.

func Deps Uses

func Deps(fns ...interface{})

Deps runs the given functions in parallel, exactly once. Dependencies must only be of type:

func()
func() error
func(context.Context)
func(context.Context) error

Or a similar method on a mg.Namespace type.

This is a way to build up a tree of dependencies with each dependency defining its own dependencies. Functions must have the same signature as a Mage target, i.e. optional context argument, optional error return.

func ExitStatus Uses

func ExitStatus(err error) int

ExitStatus queries the error for an exit status. If the error is nil, it returns 0. If the error does not implement ExitStatus() int, it returns 1. Otherwise it retiurns the value from ExitStatus().

func Fatal Uses

func Fatal(code int, args ...interface{}) error

Fatal returns an error that will cause mage to print out the given args and exit with the given exit code.

func Fatalf Uses

func Fatalf(code int, format string, args ...interface{}) error

Fatalf returns an error that will cause mage to print out the given message and exit with the given exit code.

func GoCmd Uses

func GoCmd() string

GoCmd reports the command that Mage will use to build go code. By default mage runs the "go" binary in the PATH.

func IgnoreDefault Uses

func IgnoreDefault() bool

IgnoreDefault reports whether the user has requested to ignore the default target in the magefile.

func SerialCtxDeps Uses

func SerialCtxDeps(ctx context.Context, fns ...interface{})

SerialCtxDeps is like CtxDeps except it runs each dependency serially, instead of in parallel. This can be useful for resource intensive dependencies that shouldn't be run at the same time.

func SerialDeps Uses

func SerialDeps(fns ...interface{})

SerialDeps is like Deps except it runs each dependency serially, instead of in parallel. This can be useful for resource intensive dependencies that shouldn't be run at the same time.

func Verbose Uses

func Verbose() bool

Verbose reports whether a magefile was run with the verbose flag.

type Namespace Uses

type Namespace struct{}

Namespace allows for the grouping of similar commands

Package mg imports 11 packages (graph) and is imported by 7 packages. Updated 2018-12-14. Refresh now. Tools for package owners.