mirror of
https://github.com/vbatts/talks.git
synced 2025-05-24 13:52:30 +00:00
2015-devnation: copying devconf talk
This commit is contained in:
parent
5149d7ec5e
commit
65363d37c3
18 changed files with 482 additions and 0 deletions
37
2015/06-devnation-golang-good-bad-ugly/primitive3.go
Normal file
37
2015/06-devnation-golang-good-bad-ugly/primitive3.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// START1 OMIT
|
||||
fmt.Println("I've got:")
|
||||
for card := range ReadEmAndWeep() {
|
||||
fmt.Printf(" %s of %s\n", card.Value, card.Suite)
|
||||
}
|
||||
// STOP1 OMIT
|
||||
}
|
||||
|
||||
type Card struct {
|
||||
Suite, Value string
|
||||
}
|
||||
|
||||
// START2 OMIT
|
||||
func ReadEmAndWeep() <-chan Card {
|
||||
c := make(chan Card)
|
||||
go func() {
|
||||
for _, card := range []Card{
|
||||
Card{"Ace", "Jack"},
|
||||
Card{"Ace", "Queen"},
|
||||
Card{"Ace", "King"},
|
||||
Card{"Ace", "Ace"},
|
||||
} {
|
||||
c <- card
|
||||
}
|
||||
close(c)
|
||||
}()
|
||||
return c
|
||||
}
|
||||
|
||||
// STOP2 OMIT
|
Loading…
Add table
Add a link
Reference in a new issue