github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2015/go-for-java-programmers/player.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  	player("ping", new(Ball))
    15  }
    16  
    17  func player(name string, ball *Ball) {
    18  	for i := 0; ; i++ {
    19  		ball.hits++
    20  		fmt.Println(name, i, "hit", ball.hits)
    21  		time.Sleep(100 * time.Millisecond)
    22  	}
    23  }
    24  
    25  // STOPMAIN1 OMIT