diff --git a/doc/articles/laws_of_reflection.html b/doc/articles/laws_of_reflection.html index a6175f73c1a..826a054f2e1 100644 --- a/doc/articles/laws_of_reflection.html +++ b/doc/articles/laws_of_reflection.html @@ -48,8 +48,8 @@ fixed sets of methods. An interface variable can store any concrete (non-interface) value as long as that value implements the interface's methods. A well-known pair of examples is io.Reader and io.Writer, the types -Reader and Writer from the io package: +Reader and Writer from the +io package:

{{code "/doc/progs/interface.go" `/// Reader/` `/STOP/`}} @@ -101,11 +101,10 @@ interfaces are closely related.

The representation of an interface

-Russ Cox has written a -detailed blog post about the representation of interface values -in Go. It's not necessary to repeat the full story here, but a -simplified summary is in order. +Russ Cox has written a +detailed blog post +about the representation of interface values in Go. It's not necessary to +repeat the full story here, but a simplified summary is in order.

@@ -183,9 +182,9 @@ Now we're ready to reflect. At the basic level, reflection is just a mechanism to examine the type and value pair stored inside an interface variable. To get started, there are two types we need to know about in -package reflect: -Type and -Value. Those two types +package reflect: +Type and +Value. Those two types give access to the contents of an interface variable, and two simple functions, called reflect.TypeOf and reflect.ValueOf, retrieve reflect.Type @@ -211,13 +210,11 @@ type: float64

-You might be wondering where the interface is here, since the -program looks like it's passing the float64 -variable x, not an interface value, to -reflect.TypeOf. But it's there; as godoc reports, the -signature of reflect.TypeOf includes an empty -interface: +You might be wondering where the interface is here, since the program looks +like it's passing the float64 variable x, not an +interface value, to reflect.TypeOf. But it's there; as +godoc reports, the signature of +reflect.TypeOf includes an empty interface:

@@ -573,15 +570,13 @@ fields.
 

-Here's a simple example that analyzes a struct value, -t. We create the reflection object with the address of -the struct because we'll want to modify it later. Then we set -typeOfT to its type and iterate over the fields using -straightforward method calls (see -package reflect for details). -Note that we extract the names of the fields from the struct type, -but the fields themselves are regular reflect.Value -objects. +Here's a simple example that analyzes a struct value, t. We create +the reflection object with the address of the struct because we'll want to +modify it later. Then we set typeOfT to its type and iterate over +the fields using straightforward method calls +(see package reflect for details). +Note that we extract the names of the fields from the struct type, but the +fields themselves are regular reflect.Value objects.

{{code "/doc/progs/interface2.go" `/START f8/` `/STOP/`}}