mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 02:16:48 +08:00
fix: coding style and file format for chapter 10.
This commit is contained in:
@@ -1,44 +1,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ë}
|
||||
*/
|
||||
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ë}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user