summaryrefslogtreecommitdiff
path: root/timeoutat/timeoutat.go
diff options
context:
space:
mode:
Diffstat (limited to 'timeoutat/timeoutat.go')
-rw-r--r--timeoutat/timeoutat.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/timeoutat/timeoutat.go b/timeoutat/timeoutat.go
index bf8227e..d61dba2 100644
--- a/timeoutat/timeoutat.go
+++ b/timeoutat/timeoutat.go
@@ -29,19 +29,17 @@ func TimeoutAt(
) (response chan interface{}) {
response = make(chan interface{})
go func(ctx context.Context) {
- go func() {
- if debug.IsDebug(debugLevel) {
- fmt.Printf("Timeout expected to end at %v\n", when)
- }
- select {
- case <-time.After(when.Sub(time.Now())):
- case <-ctx.Done():
- }
- response <- struct{}{}
- if debug.IsDebug(debugLevel) {
- fmt.Printf("Timeout ended at %v\n", time.Now())
- }
- }()
+ if debug.IsDebug(debugLevel) {
+ fmt.Printf("Timeout expected to end at %v\n", when)
+ }
+ select {
+ case <-time.After(when.Sub(time.Now())):
+ case <-ctx.Done():
+ }
+ response <- struct{}{}
+ if debug.IsDebug(debugLevel) {
+ fmt.Printf("Timeout ended at %v\n", time.Now())
+ }
}(ctx)
return
}