Skip to content

Commit c853797

Browse files
Matching listing ids
1 parent 7df8898 commit c853797

5 files changed

Lines changed: 17 additions & 16 deletions

File tree

chapter5/listing01/listing01

-1.84 MB
Binary file not shown.

chapter5/listing03/listing03.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ func main() {
3434

3535
// sendNotification accepts values that implement the notifier
3636
// interface and sends notifications.
37-
func sendNotification(notify notifier) {
38-
notify.notify()
37+
func sendNotification(n notifier) {
38+
n.notify()
3939
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ func main() {
3131

3232
sendNotification(u)
3333

34-
// ./listing02.go:32: cannot use u (type user) as type
34+
// ./listing34.go:32: cannot use u (type user) as type
3535
// notifier in argument to sendNotification:
3636
// user does not implement notifier
3737
// (notify method has pointer receiver)
3838
}
3939

4040
// sendNotification accepts values that implement the notifier
4141
// interface and sends notifications.
42-
func sendNotification(notify notifier) {
43-
notify.notify()
42+
func sendNotification(n notifier) {
43+
n.notify()
4444
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Sample program to show how you can't always get the address of a value.
1+
// Sample program to show how you can't always get the
2+
// address of a value.
23
package main
34

45
import "fmt"
@@ -15,6 +16,6 @@ func (d *duration) pretty() string {
1516
func main() {
1617
duration(42).pretty()
1718

18-
// ./listing04.go:16: cannot call pointer method on duration(42)
19-
// ./listing04.go:16: cannot take the address of duration(42)
19+
// ./listing44.go:16: cannot call pointer method on duration(42)
20+
// ./listing44.go:16: cannot take the address of duration(42)
2021
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ type user struct {
1717
email string
1818
}
1919

20-
// admin defines a admin in the program.
21-
type admin struct {
22-
name string
23-
email string
24-
}
25-
2620
// notify implements the notifier interface with a pointer receiver.
2721
func (u *user) notify() {
2822
fmt.Printf("Sending user Email To %s<%s>\n",
2923
u.name,
3024
u.email)
3125
}
3226

27+
// admin defines a admin in the program.
28+
type admin struct {
29+
name string
30+
email string
31+
}
32+
3333
// notify implements the notifier interface with a pointer receiver.
3434
func (a *admin) notify() {
3535
fmt.Printf("Sending admin Email To %s<%s>\n",
@@ -50,6 +50,6 @@ func main() {
5050

5151
// sendNotification accepts values that implement the notifier
5252
// interface and sends notifications.
53-
func sendNotification(notify notifier) {
54-
notify.notify()
53+
func sendNotification(n notifier) {
54+
n.notify()
5555
}

0 commit comments

Comments
 (0)