From 75e12a418517a870820b780c62ee19c8684caab8 Mon Sep 17 00:00:00 2001 From: Johan Euphrosine Date: Wed, 7 Mar 2012 11:24:00 +1100 Subject: 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 --- doc/progs/interface.go | 6 ++++++ doc/progs/interface2.go | 13 +++++++++++++ 2 files changed, 19 insertions(+) (limited to 'doc/progs') 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") -- cgit v1.2.1