Skip to content

leandroveronezi/go-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-task

Go Report Card GoDoc MIT Licensed

Go-Task is a very simple library that allows you to write simple "task" scripts in Go and run.

First, we need $GOPATH/bin

export PATH=$PATH:$GOPATH/bin

Install

go install github.com/leandroveronezi/go-task

Usage

go-task -f file.go
Parameters
    -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
Simple File

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)
}
Grouped
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

Examples

File example5.go
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)

}
Run
go-task -f example5.go -c -s
Terminal

Run Functions by name
go-task -f example5.go -c -s -t TaskH,TaskL

Releases

No releases published

Packages

No packages published

Languages