async

package
Version: v0.0.0-...-8b133c7 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Each

func Each(items interface{}, fn interface{}) (err errs.Err)
Example
package main

import (
	"math/rand"
	"time"

	"github.com/marcuswestin/fun-go/errs"
)

func main() {
	items := []string{"Foo", "Bar", "Cat"}
	var check map[string]bool
	err := Each(items, func(item string) errs.Err {
		time.After(rand.Float32() * time.Second)
		check[item] = true
	})
	assert(check["Foo"])
	assert(check["Bar"])
	assert(check["Cat"])
}

func assert(t bool) {
	if t {
		return
	}
	panic("assert failed")
}
Output:

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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