Categorygithub.com/brad-jones/goasync/v2
modulepackage
2.1.2
Repository: https://github.com/brad-jones/goasync.git
Documentation: pkg.go.dev

# README

goasync

PkgGoDev GoReport GoLang .github/workflows/main.yml semantic-release Conventional Commits KeepAChangelog License

Package goasync is a helper framework for writing asynchronous code in go. It's primary goal is to reduce the amount of boiler plate code one has to write to do concurrent tasks.

Looking for v1, see the master branch

Quick Start

go get -u github.com/brad-jones/goasync/v2/...

package main

import (
	"fmt"
	"time"

	"github.com/brad-jones/goasync/v2/await"
	"github.com/brad-jones/goasync/v2/task"
)

func doSomeWorkAsync() *task.Task {
	return task.New(func(t *task.Internal) {
		time.Sleep(1 * time.Second)
		fmt.Println("doing work")
	})
}

func main() {
	start := time.Now()
	fmt.Println("START", start)

	task1 := doSomeWorkAsync()
	task2 := doSomeWorkAsync()
	await.All(task1, task2)

	fmt.Println("END", time.Since(start))
}

Running the above will output something similar to:

START 2020-09-11 18:44:14.2406928 +1000 AEST m=+0.003027901
doing work
doing work
END 1.0013651s

Also see further working examples under: https://github.com/brad-jones/goasync/tree/v2/examples

# Packages

Package await contains await helper functions for use with tasks.
No description provided by the author
Package stop is a means of stopping many tasks in bulk.
Package task is a asynchronous utility inspired by JS Promises & C# Tasks.