nike

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 1 Imported by: 0

README

nike

nike is a simple library to run functions in parallel and return the accumulated errors, if any. It will create as many workers as there are CPUs at runtime. It is named after the ancient greek goddess of victory Nike

Usage example

package main

import "github.com/pdube/nike"


func main() {
    fns := []func() error {
        func() error {
            //do something here
            time.Sleep(time.Millisecond * 500)
            return fmt.Errorf("uninmplemented yet #1")
        },
        func() error {
            //do something here
            return fmt.Errorf("uninmplemented yet #2")
        },
    }

    errs := nike.JustDoIt(fns)
    if len(errs) > 0 {
        for i := range errs {
            fmt.Println(errs[i])
        }
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JustDoIt

func JustDoIt(funcs []func() error) []error

JustDoIt parallelizes the execution of the funcs passed in based on the number of CPUs

Types

This section is empty.

Jump to

Keyboard shortcuts

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