diff --git a/doc/effective_go.html b/doc/effective_go.html index 6adf7e55588..60e569b1387 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -1871,7 +1871,7 @@ do create a new value.) It's an idiom in Go programs to convert the type of an expression to access a different set of methods. As an example, we could use the existing -type sort.IntArray to reduce the entire example +type sort.IntSlice to reduce the entire example to this:

@@ -1879,14 +1879,14 @@ type Sequence []int
 
 // Method for printing - sorts the elements before printing
 func (s Sequence) String() string {
-    sort.IntArray(s).Sort()
+    sort.IntSlice(s).Sort()
     return fmt.Sprint([]int(s))
 }
 

Now, instead of having Sequence implement multiple interfaces (sorting and printing), we're using the ability of a data item to be -converted to multiple types (Sequence, sort.IntArray +converted to multiple types (Sequence, sort.IntSlice and []int), each of which does some part of the job. That's more unusual in practice but can be effective.

@@ -2081,8 +2081,8 @@ func ArgServer(w http.ResponseWriter, req *http.Request) {

ArgServer now has same signature as HandlerFunc, so it can be converted to that type to access its methods, -just as we converted Sequence to IntArray -to access IntArray.Sort. +just as we converted Sequence to IntSlice +to access IntSlice.Sort. The code to set it up is concise:

diff --git a/doc/effective_go.tmpl b/doc/effective_go.tmpl
index 46d774ad4ef..da827368b1c 100644
--- a/doc/effective_go.tmpl
+++ b/doc/effective_go.tmpl
@@ -1809,7 +1809,7 @@ do create a new value.)
 It's an idiom in Go programs to convert the
 type of an expression to access a different
 set of methods. As an example, we could use the existing
-type sort.IntArray to reduce the entire example
+type sort.IntSlice to reduce the entire example
 to this:
 

@@ -1817,14 +1817,14 @@ type Sequence []int
 
 // Method for printing - sorts the elements before printing
 func (s Sequence) String() string {
-    sort.IntArray(s).Sort()
+    sort.IntSlice(s).Sort()
     return fmt.Sprint([]int(s))
 }
 

Now, instead of having Sequence implement multiple interfaces (sorting and printing), we're using the ability of a data item to be -converted to multiple types (Sequence, sort.IntArray +converted to multiple types (Sequence, sort.IntSlice and []int), each of which does some part of the job. That's more unusual in practice but can be effective.

@@ -2019,8 +2019,8 @@ func ArgServer(w http.ResponseWriter, req *http.Request) {

ArgServer now has same signature as HandlerFunc, so it can be converted to that type to access its methods, -just as we converted Sequence to IntArray -to access IntArray.Sort. +just as we converted Sequence to IntSlice +to access IntSlice.Sort. The code to set it up is concise: