mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 04:48:29 +08:00
46 lines
1.1 KiB
Go
Executable File
46 lines
1.1 KiB
Go
Executable File
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ë}
|
|
*/
|