This commit is contained in:
Mark McGranaghan 2012-09-16 16:12:00 -07:00
parent 4ea9f21bdc
commit 6a9c1731b3
4 changed files with 70 additions and 0 deletions

24
00-notes.txt Normal file
View File

@ -0,0 +1,24 @@
= distribution
* leading blog posts
* a new kind of programming book
* minimize text, maximize examples
* focus on working programs
* syntax highlighting
* select, actors, threads, and event loops
* small go programming examples
* newsletter
* twitter
* stack overflow answers
= pricing
* high
* updates
* no drm
* offers of free books in comments
= source
* popular github libraries
* mailing list questions
* stack overflow questions
* handbook format
* rosetta stone

26
37-concurrency.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"fmt"
"time"
"math/rand"
)
func f(n int) {
for i := 0; i < 10; i++ {
fmt.Println(n, ":", i)
time.Sleep(time.Millisecond * time.Duration(rand.Intn(150)))
}
}
func main() {
for i := 0; i < 5; i++ {
f(i)
}
fmt.Println()
for i := 0; i < 5; i++ {
go f(i)
}
var input string
fmt.Scanln(&input)
}

10
38-channels.go Normal file
View File

@ -0,0 +1,10 @@
package main
import "fmt"
func main() {
var messages chan string = make(chan string)
go func() { messages <- "ping"}()
msg := <- messages
fmt.Println(msg)
}

10
39-buffering.go Normal file
View File

@ -0,0 +1,10 @@
package main
import "fmt"
func main() {
var messages chan string = make(chan string, 1)
messages <- "ping"
msg := <- messages
fmt.Println(msg)
}