Categorygithub.com/WinPooh32/async/v2
package
2.0.2
Repository: https://github.com/winpooh32/async.git
Documentation: pkg.go.dev

# README

Async

test Go Reference

Run async code with safe!

Example

package main

import (
	"context"
	"fmt"

	"github.com/WinPooh32/async"
)

func main() {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	fn := func(ch chan<- async.Option[string]) error {
		err := async.TrySend(ctx, ch, "Hello Async!")
		if err != nil {
			return err
		}

		return nil
	}

	ch := async.Go(ctx, fn)

	value, err := async.Await(ctx, ch)
	if err != nil {
		panic(err)
	}

	fmt.Println(value)
}

Look for more examples at async_test.go