Go-Task is a very simple library that allows you to write simple "task" scripts in Go and run.
export PATH=$PATH:$GOPATH/bin
go install github.com/leandroveronezi/go-task
go-task -f file.go
-f File
-silent Silent mode
-k Keep generated file
-w View generated source
-s Sort orders of functions by name before run
-c Skip errors and continue
-t Target functions
-g Run function by group
An import between parenthesis is required.
Run only Exported functions.
No main function allowed
package example
import (
"time"
)
func TaskA() {
time.Sleep(1 * time.Second)
}
package example
import (
"time"
)
// group:dev,prod
func TaskA() {
time.Sleep(1 * time.Second)
}
// group:dev
func TaskB() {
time.Sleep(1 * time.Second)
}
// group:prod
func TaskC() {
time.Sleep(1 * time.Second)
}
go-task -f file.go -g dev
package example
import (
"github.com/pkg/errors"
"time"
)
func TaskN() error {
time.Sleep(1 * time.Second)
return errors.New("An error")
}
func TaskM() bool {
time.Sleep(1 * time.Second)
return false
}
func TaskL() bool {
time.Sleep(1 * time.Second)
return true
}
func TaskK() error {
time.Sleep(1 * time.Second)
return nil
}
func TaskJ() {
time.Sleep(1 * time.Second)
}
func TaskH() {
taskI()
}
func taskI() {
time.Sleep(1 * time.Second)
}
go-task -f example5.go -c -s
go-task -f example5.go -c -s -t TaskH,TaskL