Promise is a disposable write-once latch, to act as a synchronization barrier to signal completion of some asynchronous operation (successful or otherwise).
Functions that operate on this type (IsComplete, Complete, Await, AwaitUntil) are idempotent and thread-safe.
package main
import (
"fmt"
"github.com/ConnorDoyle/promise"
)
func main() {
p := promise.New()
go p.Complete(nil)
p.Await()
fmt.Println("goroutine ran")
}
...and never rely on Sleep
in test code again!