vcard.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. type Address struct {
  7. Street string
  8. HouseNumber uint32
  9. HouseNumberAddOn string
  10. POBox string
  11. ZipCode string
  12. City string
  13. Country string
  14. }
  15. type VCard struct {
  16. FirstName string
  17. LastName string
  18. NickName string
  19. BirtDate time.Time
  20. Photo string
  21. Addresses map[string]*Address
  22. }
  23. func main() {
  24. addr1 := &Address{"Elfenstraat", 12, "", "", "2600", "Mechelen", "België"}
  25. addr2 := &Address{"Heideland", 28, "", "", "2640", "Mortsel", "België"}
  26. addrs := make(map[string]*Address)
  27. addrs["youth"] = addr1
  28. addrs["now"] = addr2
  29. birthdt := time.Date(1956, 1, 17, 15, 4, 5, 0, time.Local)
  30. photo := "MyDocuments/MyPhotos/photo1.jpg"
  31. vcard := &VCard{"Ivo", "Balbaert", "", birthdt, photo, addrs}
  32. fmt.Printf("Here is the full VCard: %v\n", vcard)
  33. fmt.Printf("My Addresses are:\n %v\n %v", addr1, addr2)
  34. }
  35. /* Output:
  36. Here is the full VCard: &{Ivo Balbaert Sun Jan 17 15:04:05 +0000 1956 MyDocuments/MyPhotos/photo1.jpg map[now:0x126d57c0 youth:0x126d5500]}
  37. My Addresses are:
  38. &{Elfenstraat 12 2600 Mechelen België}
  39. &{Heideland 28 2640 Mortsel België}
  40. */