fix: coding style and file format for chapter 10.

This commit is contained in:
Bo-Yi Wu
2017-02-11 12:28:43 +08:00
parent d9041c7fc3
commit ca79293078
19 changed files with 731 additions and 720 deletions

View File

@@ -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ë}
*/