summaryrefslogtreecommitdiff
path: root/timeoutat/timeoutat.go
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2023-02-10 18:13:03 -0500
committerWill Hawkins <[email protected]>2023-02-10 18:13:03 -0500
commit0eafb34d7e2c9971c9341878a7c1d3ffa034418b (patch)
tree1ce060ef70254b465baedfc535d418ee231f6aeb /timeoutat/timeoutat.go
parentc8350c13a09b8c19656cd32a065b69693b6117c5 (diff)
[Cleanup] Update timeoutat.TimeoutAt to remove extraneous go func
Also, add a test for timeoutat.TimeoutAt.
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
}