File: example_test.go

package info (click to toggle)
mage 1.15.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 756 kB
  • sloc: makefile: 14
file content (29 lines) | stat: -rw-r--r-- 633 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package mg_test

import (
	"fmt"

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

func Example() {
	// Deps will run each dependency exactly once, and will run leaf-dependencies before those
	// functions that depend on them (if you put mg.Deps first in the function).

	// Normal (non-serial) Deps runs all dependencies in goroutines, so which one finishes first is
	// non-deterministic. Here we use SerialDeps here to ensure the example always produces the same
	// output.

	mg.SerialDeps(mg.F(Say, "hi"), Bark)
	// output:
	// hi
	// woof
}

func Say(something string) {
	fmt.Println(something)
}

func Bark() {
	mg.Deps(mg.F(Say, "woof"))
}