diff --git a/mgx/doc.go b/mgx/doc.go new file mode 100644 index 0000000..191ff9d --- /dev/null +++ b/mgx/doc.go @@ -0,0 +1,3 @@ +// Package mgx provides helpers that complement the github.com/magefile/mage/mg package. +// They are general purpose functions that assist with writing magefiles. +package mgx diff --git a/mgx/must.go b/mgx/must.go index 901b427..b74f65d 100644 --- a/mgx/must.go +++ b/mgx/must.go @@ -2,7 +2,12 @@ package mgx import "github.com/magefile/mage/mg" -// Must stops the build when an error occurs. +// Must stops execution by throwing a panic when an error occurs. +// +// This may be used to keep your magefile brief, and mimic set -euo in an +// equivalent bash script. This pattern works well in magefile targets only, not +// helper functions. For helper functions, return an error so that you can write +// tests and allow the calling function to handle the error. func Must(err error) { if err != nil { panic(mg.Fatal(1, err))