File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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.
23package main
34
45import "fmt"
@@ -15,6 +16,6 @@ func (d *duration) pretty() string {
1516func 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}
Original file line number Diff line number Diff 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.
2721func (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.
3434func (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}
You can’t perform that action at this time.
0 commit comments