aboutsummaryrefslogtreecommitdiff
path: root/content/methods/exercise-stringer.go
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2014-07-30 10:50:51 +1000
committerAndrew Gerrand <adg@golang.org>2014-07-30 10:50:51 +1000
commiteff9b7ba0df29aaa882be16def4b79cc207055f8 (patch)
tree094440bc88a4769a9e77eff1bb149e0ecee7cfd4 /content/methods/exercise-stringer.go
parentf82b5da64d2d1a0de764ca341592c8ecf83079f1 (diff)
downloadgolang-id-tour-eff9b7ba0df29aaa882be16def4b79cc207055f8.tar.xz
go-tour: add Stringer, Reader discussions and exercises; other tweaks
LGTM=campoy R=campoy CC=golang-codereviews https://golang.org/cl/118170043
Diffstat (limited to 'content/methods/exercise-stringer.go')
-rw-r--r--content/methods/exercise-stringer.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/content/methods/exercise-stringer.go b/content/methods/exercise-stringer.go
new file mode 100644
index 0000000..ef656b4
--- /dev/null
+++ b/content/methods/exercise-stringer.go
@@ -0,0 +1,17 @@
+package main
+
+import "fmt"
+
+type IPAddr [4]byte
+
+// TODO: Add a "String() string" method to IPAddr.
+
+func main() {
+ addrs := map[string]IPAddr{
+ "loopback": {127, 0, 0, 1},
+ "googleDNS": {8, 8, 8, 8},
+ }
+ for n, a := range addrs {
+ fmt.Printf("%v: %v\n", n, a)
+ }
+}