Created
September 27, 2018 13:13
-
-
Save ph/f532130e14631e5e023da12fa7ef1e24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
type OK struct{} | |
func main() { | |
ch := make(chan *OK) | |
var wg sync.WaitGroup | |
wg.Add(1) | |
go func() { | |
defer wg.Done() | |
for { | |
select { | |
case v := <-ch: | |
fmt.Println(v) | |
time.Sleep(1 * time.Second) | |
} | |
} | |
}() | |
ch <- &OK{} | |
close(ch) | |
wg.Wait() | |
fmt.Println("vim-go") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment