3.0.0
·
10 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
This major release improves the command-line interface and changes the A.Context behavior to match testing.T.Context.
Migration Guide from v2 to v3
Module Path Change
Update your import statements and go.mod.
// Before (v2)
import "github.com/goyek/goyek/v2"
// After (v3)
import "github.com/goyek/goyek/v3"Command Line Syntax Change
The recommended command line syntax changed from [flags] [--] [tasks] to
[tasks] [flags] [--] [args].
// Before (v2)
func main() {
flag.Parse()
goyek.Main(flag.Args())
}
// After (v3)
func main() {
tasks, rest := goyek.SplitTasks(os.Args[1:])
flag.CommandLine.Parse(rest)
goyek.Main(tasks)
}Context Behavior Change
A.Context is now canceled just before cleanup functions are called. If your cleanup functions depend on the context being active, they will continue to work. If your code depended on the context remaining active after cleanup, it will need adjustment.
// Before (v2): Context stayed active during cleanup.
goyek.Define(goyek.Task{
Name: "example",
Action: func(a *goyek.A) {
a.Cleanup(func() {
// Context was still active here.
})
},
})
// After (v3): Context cancels before cleanup (matches testing.T behavior).
goyek.Define(goyek.Task{
Name: "example",
Action: func(a *goyek.A) {
a.Cleanup(func() {
// Context is canceled here, allowing proper shutdown
// of resources that listen to context.Done().
})
},
})Added
- Add
SplitTasksfunction to split command line arguments into tasks and rest. This allows tasks to come before flags and usage of positional arguments.
Changed
- BREAKING: Change module path to
github.com/goyek/goyek/v3. - BREAKING: Change
A.Contextbehavior to be canceled just before cleanup functions are called, matchingtesting.T.Contextbehavior. The context still cancels when the original context is canceled (e.g. flow interruption). This ensures cleanup functions can wait for resources that shut down oncontext.Context.Donebefore the task action completes.