summaryrefslogtreecommitdiff
path: root/doc/progs/print_string.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-01-09 15:16:31 -0800
committerRob Pike <r@golang.org>2009-01-09 15:16:31 -0800
commitbc23ce679061b8f41f551578181b9feeb24f5c0a (patch)
tree64f4931996e82c6dff92d3c7647814b7c43469b3 /doc/progs/print_string.go
parent0509e08028f63b53b65f294e06d603ccfdb76c22 (diff)
downloadgolang-bc23ce679061b8f41f551578181b9feeb24f5c0a.tar.gz
update tutorial to new language.
add a section on printing add a section on allocation R=rsc DELTA=500 (278 added, 15 deleted, 207 changed) OCL=22381 CL=22456
Diffstat (limited to 'doc/progs/print_string.go')
-rw-r--r--doc/progs/print_string.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/progs/print_string.go b/doc/progs/print_string.go
new file mode 100644
index 000000000..47d4a4b9d
--- /dev/null
+++ b/doc/progs/print_string.go
@@ -0,0 +1,18 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "fmt"
+
+type T struct { a int; b string }
+
+func (t *T) String() string {
+ return fmt.sprint(t.a) + " " + t.b
+}
+
+func main() {
+ t := &T{77, "Sunset Strip"};
+ fmt.println(t)
+}