This is a very stupid Promise implementation in golang.
$ go get github.com/march1993/gopromise
Only one function called Promise
is exported.
package somepackage
import . "github.com/march1993/gopromise"
func () {
// create a promise
Promise(func(resolve func(interface{}), reject func(error)) {
// call resolve or reject
}).Then(func(value interface{}) interface{} {
return something
}, func(reason error) interface{} {
return something
}).Catch(func(reason error) interface{} {
return something
})
// create a resolved promise
Promise.Resolve(something).Then().Catch()
// create a rejected promise
Promise.Rejected(something).Then().Catch()
}
See here.