Golang time.After() function example
package time
Golang time.After() function usage example
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan bool, 1)
go func() {
select {
case m := <-c:
// do something
handle(m)
case <-time.After(3 * time.Second):
fmt.Println("timed out")
}
}()
time.Sleep(5 * time.Second)
}
func handle(m bool) {}
Play at : http://play.golang.org/p/mWtdvxppu_
Reference :
Advertisement
Something interesting
Tutorials
+12.7k Golang : Sort and reverse sort a slice of bytes
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+7.8k Golang : Load DSA public key from file example
+9.9k Golang : ffmpeg with os/exec.Command() returns non-zero status
+9.4k Golang : Play .WAV file from command line
+6.5k Golang : Spell checking with ispell example
+80.6k Golang : How to return HTTP status code?
+21.1k Golang : Get password from console input without echo or masked
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+14k Golang : convert rune to unicode hexadecimal value and back to rune character
+8.2k Prevent Write failed: Broken pipe problem during ssh session with screen command