parallel

package module
v0.0.0-...-0890dde Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

README

Parallel

Build Status Go Report Card GoDoc

Parallel's Group make goroutine run & wait easy.

It automatically check if the last parameter of your function is an error, and return it through Wait()

Installation

Install Parallel using go get:

```sh
$ go get github.com/wayt/parallel
```

Example

package main

import (
        "fmt"
        "github.com/wayt/parallel"
)

func main() {

        g := &parallel.Group{}

        g.Go(func(text string) {
                fmt.Println(text)
        }, "Hello World !")

        g.Go(func() error {
                return fmt.Errorf("something bad happened =/")
        })

        if err := g.Wait(); err != nil {
                fmt.Printf("Got an error: %v\n", err)
        }
}

Contributing

Please feel free to submit issues, fork the repository and send pull requests!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group is a goroutine group

func (*Group) Go

func (g *Group) Go(fun interface{}, args ...interface{})

Go run a goroutine fun MUST be a function, if the last return parameter is an error, I'll be push to errs chan args are fun parameters, optional

func (*Group) Wait

func (g *Group) Wait() error

Wait block until all goroutine has finished return the last error if any it may skip error since it only return the last one, workaround ?

Jump to

Keyboard shortcuts

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