🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/kogutich/go-async

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/kogutich/go-async

v0.0.0-20240707172239-89a7e3e5e40e
Source
Go
Version published
Created
Source

go-async

Library that provides promise-like functionality for running functions asynchronously.

Usage

Imagine a function that takes some time to complete.
And we want to run it asynchronously and later take the results.

f := func() (string, error) {
    time.Sleep(time.Second)
    return "Hello world", nil
}
  • Start a function and save the promise (under the hood it runs in a separate goroutine):
promise := async.RunVE(f)
  • Wait for results:
value, err := promise.Wait()

Naming

RunVE means we run function that returns Value and Error.
Supported functions described here. Each function type has its own Run* method.

FAQs

Package last updated on 07 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts