]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/os/signal/example_unix_test.go
os/signal: remove some arbitrary timeouts in tests
[gostls13.git] / src / os / signal / example_unix_test.go
index b7047ac45cdf2c5f83c11582394d4aa36e652e0d..583d4e4089f52f82ada6218ca7362b9ed4ffbe23 100644 (file)
@@ -12,9 +12,10 @@ import (
        "log"
        "os"
        "os/signal"
-       "time"
 )
 
+var neverReady = make(chan struct{}) // never closed
+
 // This example passes a context with a signal to tell a blocking function that
 // it should abandon its work after a signal is received.
 func ExampleNotifyContext() {
@@ -35,8 +36,8 @@ func ExampleNotifyContext() {
        }
 
        select {
-       case <-time.After(time.Second):
-               fmt.Println("missed signal")
+       case <-neverReady:
+               fmt.Println("ready")
        case <-ctx.Done():
                fmt.Println(ctx.Err()) // prints "context canceled"
                stop()                 // stop receiving signal notifications as soon as possible.