github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2015/go-for-java-programmers/goroutine.go (about) 1 // +build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "time" 8 ) 9 10 // STARTMAIN1 OMIT 11 type Ball struct{ hits int } 12 13 func main() { 14 go player("ping", new(Ball)) // HL 15 time.Sleep(1 * time.Second) 16 } 17 18 func player(name string, ball *Ball) { 19 for i := 0; ; i++ { 20 ball.hits++ 21 fmt.Println(name, i, "hit", ball.hits) 22 time.Sleep(100 * time.Millisecond) 23 } 24 } 25 26 // STOPMAIN1 OMIT