Guest User

Untitled

a guest
Sep 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. type IPAddr [4]byte
  6.  
  7. func (ipAddr IPAddr) String() string {
  8. return fmt.Sprintf("%d.%d.%d.%d", ipAddr[0], ipAddr[1], ipAddr[2], ipAddr[3])
  9. }
  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. }
Add Comment
Please, Sign In to add comment