diff --git a/mage/magefile_tmpl.go b/mage/magefile_tmpl.go index 01b87860..1df97037 100644 --- a/mage/magefile_tmpl.go +++ b/mage/magefile_tmpl.go @@ -1,6 +1,7 @@ package mage -var mageTpl = `// +build mage +var mageTpl = `//go:build mage +// +build mage package main diff --git a/mage/testdata/mageimport/magefile.go b/mage/testdata/mageimport/magefile.go index f5d286f5..f37a8953 100644 --- a/mage/testdata/mageimport/magefile.go +++ b/mage/testdata/mageimport/magefile.go @@ -12,9 +12,9 @@ package main import ( "fmt" - // mage:import + //mage:import _ "github.com/magefile/mage/mage/testdata/mageimport/subdir1" - // mage:import zz + //mage:import zz "github.com/magefile/mage/mage/testdata/mageimport/subdir2" ) diff --git a/mage/testdata/mageimport/oneline/magefile.go b/mage/testdata/mageimport/oneline/magefile.go index b6bd5ea8..fdbbc213 100644 --- a/mage/testdata/mageimport/oneline/magefile.go +++ b/mage/testdata/mageimport/oneline/magefile.go @@ -2,5 +2,5 @@ package main -// mage:import +//mage:import import _ "github.com/magefile/mage/mage/testdata/mageimport/oneline/other" diff --git a/mage/testdata/mageimport/tagged/magefile.go b/mage/testdata/mageimport/tagged/magefile.go index 027ed904..c04d933b 100644 --- a/mage/testdata/mageimport/tagged/magefile.go +++ b/mage/testdata/mageimport/tagged/magefile.go @@ -3,6 +3,6 @@ package main import ( - // mage:import + //mage:import _ "github.com/magefile/mage/mage/testdata/mageimport/tagged/pkg" ) diff --git a/parse/testdata/importself/magefile.go b/parse/testdata/importself/magefile.go index e448a84c..e1978e52 100644 --- a/parse/testdata/importself/magefile.go +++ b/parse/testdata/importself/magefile.go @@ -5,10 +5,10 @@ package main import ( "fmt" - // mage:import + //mage:import _ "github.com/magefile/mage/parse/testdata/importself" ) -func Build(){ +func Build() { fmt.Println("built") -} \ No newline at end of file +} diff --git a/site/content/howitworks/_index.en.md b/site/content/howitworks/_index.en.md index 699356af..57e3be81 100644 --- a/site/content/howitworks/_index.en.md +++ b/site/content/howitworks/_index.en.md @@ -4,7 +4,7 @@ weight = 50 +++ Mage scans the current directory for go files with the `mage` build tag (i.e. -`// +build mage`), using the normal go build rules for following build +`//go:build mage`), using the normal go build rules for following build constraints (aside from requiring the mage tag). It then parses those files to find the build targets, generates a main file for the command, and compiles a binary from those files. The magefiles are hashed so that if they remain diff --git a/site/content/importing/_index.en.md b/site/content/importing/_index.en.md index ff1f300d..db469a01 100644 --- a/site/content/importing/_index.en.md +++ b/site/content/importing/_index.en.md @@ -16,7 +16,7 @@ let you import a main package. In addition, all package files will be imported, so long as they don't have a build tag. If you try to import a package consisting only of files with build -tags (e.g. `//+build mage`), it will cause an error since mage doesn't set any +tags (e.g. `//go:build mage`), it will cause an error since mage doesn't set any build tags when importing packages. Any exported function, in imported packages, that matches Mage's allowed formats will be picked up as a target. @@ -27,15 +27,15 @@ like a normal magefile. ## Two Ways to Import -Importing targets from a package simply requires adding a `// mage:import` +Importing targets from a package simply requires adding a `//mage:import` comment on an import statement in your magefile. If there is a name after this tag, the targets will be imported into what is effectively like a namespace. ```go import ( - // mage:import + //mage:import _ "example.com/me/foobar" - // mage:import build + //mage:import build "example.com/me/builder" ) ``` diff --git a/site/content/index.md b/site/content/index.md index ac0f860a..81115343 100644 --- a/site/content/index.md +++ b/site/content/index.md @@ -70,7 +70,7 @@ asdf global mage latest ## Example Magefile ```go -//+build mage +//go:build mage package main diff --git a/site/content/magefiles/_index.en.md b/site/content/magefiles/_index.en.md index dcfb4bda..55fa4898 100644 --- a/site/content/magefiles/_index.en.md +++ b/site/content/magefiles/_index.en.md @@ -8,7 +8,7 @@ A mage file is any regular go file marked with a build target of "mage" and in package main. ```go -// +build mage +//go:build mage package main ``` @@ -25,7 +25,7 @@ use any of Go's usual build constraints, so you can include and exclude magefiles based on OS, arch, etc, whether in the filename or in the +build line. ```go -// +build mage +//go:build mage // A comment on the package will be output when you list the targets of a // magefile. diff --git a/site/content/zeroInstall/_index.en.md b/site/content/zeroInstall/_index.en.md index 8f71735c..1a7b1c98 100644 --- a/site/content/zeroInstall/_index.en.md +++ b/site/content/zeroInstall/_index.en.md @@ -8,7 +8,7 @@ Don't want to depend on another binary in your environment? You can run mage directly out of your vendor directory (or GOPATH) with `go run`. Just save a file like this (I'll call it `mage.go`, but it can be named -anything) and note that the build tag is *not* `+build mage`. Mage will +anything) and note that the build tag is *not* `go:build mage`. Mage will create its own main file, so we need this one to be excluded from when your magefiles are compiled.