Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hadihammurabi/asynks

Run asynchronous tasks in Go
https://github.com/hadihammurabi/asynks

Last synced: about 2 months ago
JSON representation

Run asynchronous tasks in Go

Awesome Lists containing this project

README

        

# asynks
Run asynchronous tasks in Go.

> Inspired by Promise methods in JS

# Features
* Run functions asynchronously
* Clear API
* Remove goroutine complexity

# Example
```go
package main

import (
"fmt"

// Import asynks
"github.com/hadihammurabi/asynks"
)

func main() {
// Use asynks.All to run all functions asynchronously
results, err := asynks.All(
func() (interface{}, error) {
return 1, nil
},
func() (interface{}, error) {
return 2, nil
},
func() (interface{}, error) {
return 3, nil
},
)

// Panic on error and print the results
if err != nil {
panic(err)
}
fmt.Println(results)
}
```