Source file tour/methods/exercise-stringer.go

     1  // +build OMIT
     2  
     3  package main
     4  
     5  import "fmt"
     6  
     7  type IPAddr [4]byte
     8  
     9  // TODO: Add a "String() string" method to IPAddr.
    10  
    11  func main() {
    12  	hosts := map[string]IPAddr{
    13  		"loopback":  {127, 0, 0, 1},
    14  		"googleDNS": {8, 8, 8, 8},
    15  	}
    16  	for name, ip := range hosts {
    17  		fmt.Printf("%v: %v\n", name, ip)
    18  	}
    19  }
    20  

View as plain text