Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

14 Commits

Repository files navigation

VGo

The library helps you have the async-await syntax in Go that runs on goroutines.

Install

go get github.com/VennDev/VGo

Example

package vgo
import (
"fmt""strconv""testing"
)
funcdoAsync() *Async {
return&Async{
Callback: func() interface{} {
return30
},
}
}
funcTestAsync(t*testing.T) {
async:=doAsync()
result:=Await(async)
fmt.Println("Result async:", strconv.Itoa(result.(int))) // Output: Result async: 30
}
funcTestDeferred(t*testing.T) {
deferred:=&Deferred{
Callback: func() interface{} {
return50
},
}
result:=deferred.Await()
fmt.Println("Result deferred:", strconv.Itoa(result.(int))) // Output: Result deferred: 50
}
funcTestDeferredAll(t*testing.T) {
deferred:=&Deferred{}
result:=deferred.All(
func() interface{} {
return10
},
func() interface{} {
return20
},
func() interface{} {
return30
},
).Await()
fmt.Println("Result deferred all:", result) // Output: Result deferred all: [10 20 30]
}
funcTestDeferredAny(t*testing.T) {
deferred:=&Deferred{}
result:=deferred.Any(
func() interface{} {
return10
},
func() interface{} {
return20
},
func() interface{} {
return30
},
).Await()
fmt.Println("Result deferred any:", result) // Output: Result deferred any: 10
}

About

The library helps you have the async-await syntax in Go that runs on goroutines.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages