Skip to content

Instantly share code, notes, and snippets.

@shadedyin
Created February 14, 2015 21:43
Show Gist options
  • Save shadedyin/dfe759736848ff095426 to your computer and use it in GitHub Desktop.
Save shadedyin/dfe759736848ff095426 to your computer and use it in GitHub Desktop.
package hold
import (
"time"
)
func Hold(read chan interface{}, timeout time.Duration) interface{} {
var result interface{}
for {
select {
case <-time.After(timeout * time.Second):
return result
case result = <-read:
// update tmp
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment