easy timeout in golang
go get github.com/flybikeGx/easy-timeout
import "github.com/flybikeGx/easy-timeout/timelimit"
ok := timelimit.Run(1*time.Second, func() {
// your closure, main thread will be blocked
})
if !ok {
// handle time out
}
- Thread safe
- Stop at the exact time as golang timer
Closure safety should take care of