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