summaryrefslogtreecommitdiff
path: root/doc/progs
diff options
context:
space:
mode:
authorJohan Euphrosine <proppy@google.com>2012-03-07 11:24:00 +1100
committerJohan Euphrosine <proppy@google.com>2012-03-07 11:24:00 +1100
commit75e12a418517a870820b780c62ee19c8684caab8 (patch)
tree45ee253b953f8bcaca096c9ecd1e193d9d690004 /doc/progs
parenta1e1a83f5e762714510e604d170b8fe046eb3fa6 (diff)
downloadgo-75e12a418517a870820b780c62ee19c8684caab8.tar.gz
doc: fix typos in laws_of_reflection article, add copyright notice.
Update issue 2547. R=golang-dev, minux.ma, r, r, adg CC=golang-dev http://codereview.appspot.com/5755051 Committer: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'doc/progs')
-rw-r--r--doc/progs/interface.go6
-rw-r--r--doc/progs/interface2.go13
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/progs/interface.go b/doc/progs/interface.go
index 91145401e..c2925d590 100644
--- a/doc/progs/interface.go
+++ b/doc/progs/interface.go
@@ -1,3 +1,9 @@
+// Copyright 2012 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.
+
+// This file contains the code snippets included in "The Laws of Reflection."
+
package main
import (
diff --git a/doc/progs/interface2.go b/doc/progs/interface2.go
index e2716cf16..2deba32b4 100644
--- a/doc/progs/interface2.go
+++ b/doc/progs/interface2.go
@@ -1,3 +1,9 @@
+// Copyright 2012 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.
+
+// This file contains the code snippets included in "The Laws of Reflection."
+
package main
import (
@@ -39,11 +45,14 @@ func f3() {
type MyInt int
var x MyInt = 7
v := reflect.ValueOf(x)
+ // STOP OMIT
// START f3b OMIT
y := v.Interface().(float64) // y will have type float64.
fmt.Println(y)
+ // STOP OMIT
// START f3c OMIT
fmt.Println(v.Interface())
+ // STOP OMIT
// START f3d OMIT
fmt.Printf("value is %7.1e\n", v.Interface())
// STOP OMIT
@@ -69,6 +78,7 @@ func f6() {
// START f6 OMIT
var x float64 = 3.4
v := reflect.ValueOf(x)
+ // STOP OMIT
// START f6b OMIT
v.SetFloat(7.1)
// STOP OMIT
@@ -80,9 +90,11 @@ func f7() {
p := reflect.ValueOf(&x) // Note: take the address of x.
fmt.Println("type of p:", p.Type())
fmt.Println("settability of p:", p.CanSet())
+ // STOP OMIT
// START f7b OMIT
v := p.Elem()
fmt.Println("settability of v:", v.CanSet())
+ // STOP OMIT
// START f7c OMIT
v.SetFloat(7.1)
fmt.Println(v.Interface())
@@ -104,6 +116,7 @@ func f8() {
fmt.Printf("%d: %s %s = %v\n", i,
typeOfT.Field(i).Name, f.Type(), f.Interface())
}
+ // STOP OMIT
// START f8b OMIT
s.Field(0).SetInt(77)
s.Field(1).SetString("Sunset Strip")