go-task

command module
v0.0.0-...-b15ae75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 1 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL