mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-23 05:06:01 +03:00
22 lines
250 B
Go
22 lines
250 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// demostration of channel and timeout
|
|
func main() {
|
|
ourChan := make(chan string, 1)
|
|
|
|
go func() {
|
|
|
|
}()
|
|
|
|
select {
|
|
case <-time.After(10 * time.Second):
|
|
fmt.Println("Enough waiting")
|
|
close(ourChan)
|
|
}
|
|
}
|