Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring docs for use of directives up to date #407

Merged
merged 3 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mage/magefile_tmpl.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mage

var mageTpl = `// +build mage
var mageTpl = `//go:build mage
// +build mage

package main

Expand Down
4 changes: 2 additions & 2 deletions mage/testdata/mageimport/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion mage/testdata/mageimport/oneline/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

package main

// mage:import
//mage:import
import _ "github.com/magefile/mage/mage/testdata/mageimport/oneline/other"
2 changes: 1 addition & 1 deletion mage/testdata/mageimport/tagged/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
package main

import (
// mage:import
//mage:import
_ "github.com/magefile/mage/mage/testdata/mageimport/tagged/pkg"
)
6 changes: 3 additions & 3 deletions parse/testdata/importself/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
2 changes: 1 addition & 1 deletion site/content/howitworks/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions site/content/importing/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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"
)
```
Expand Down
2 changes: 1 addition & 1 deletion site/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ asdf global mage latest
## Example Magefile

```go
//+build mage
//go:build mage

package main

Expand Down
4 changes: 2 additions & 2 deletions site/content/magefiles/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion site/content/zeroInstall/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down