Marcel Lanz (6) [Avatar] Offline
#1
Hi
Great chapter. I've read chapter 4 in V3 and have some comments. hope they help.
Marcel

Go_in_Action_v3_MEAP
PDF

p72:
Listing 4.7
// Declare a string array of three elements.
var array1 [5]string

> should be:
// Declare a string array of five elements.
var array1 [5]string

p76:
Listing 4.12

// Declare two different two dimensional integer arrays.
var array1 [2][2]int
var array2 [2][2]int
// Add integer values to each individual element.
array[0][0] = 10
array[0][1] = 20
array[1][0] = 30
array[1][1] = 40
// Copy the values from array2 into array1.
array2 = array1

> you write, to copy the values from array2 to array1
> so this should be:

// Declare two different two dimensional integer arrays.
var array1 [2][2]int
var array2 [2][2]int
// Add integer values to each individual element.
array2[0][0] = 10
array2[0][1] = 20
array2[1][0] = 30
array2[1][1] = 40
// Copy the values from array2 into array1.
array1 = array2

> or the other way around

p76:
To see what I mean, let's create an array of one million elements of type integer.

> you use 1st person form: "what I mean", haven't check that throughout of the book, but until now its not written in this style?

p76:
On a 64 bit architecture, that would require 80 million bytes or 8 megs of memory.

> an int or int64 is 8 bytes on 64 bit machines; 1e6 * 8 bytes are 8e6 => 8 million bytes or 8 megabytes. You use "8 megs of memory". "megs" is perhaps some kind of slang? it could also be megabytes or MB since this is Base 10 calculated.

p77:
Figure 4.10
> here "Megs" and "Meg" are used mixed and inconistent.

p79:
In many use-cases, slices out perform other types of dynamic data structures

> could be:
In many use-cases, slices outperform other types of dynamic data structures

p79:
Figure 4.12
Difference between a linked list and slice

> could be:
Difference between a linked list and a slice

p80:
Depending on whether we know the capacity we need ahead of time, will usually determine how we go about it.

> this part seems a bit odd:
"we need ahead of time, will usually determine"

p83:
This is very different from a nil slice because an empty slice does contain its internal data structure.

> here nil is italized (italic font format). on the next sentence not.

p84:
Figure 4.15
The representation of an Empty Slice

> here you name it "Empty Slice", on other figures and also 4.14 its a "nil slice"
could be:
The representation of an empty slice

p97:
fmt.Printf("Value: %d Value-Addr: %x ElemAddr: %x
",

the output is upper case HEX:
alue: 10 Value-Addr: FF10 ElemAddr: FDD0

so this should be:
fmt.Printf("Value: %d Value-Addr: %X ElemAddr: %X
",

> see http://play.golang.org/p/aanzAfgoO1


p103:
they could be returned to us in a different order. This is because a map is implemented as a hash table.

> in fact, hashmap has implemented random order of key/value if we iterate over it:
> see: hash_iter_init in https://code.google.com/p/go/source/browse/src/pkg/runtime/hashmap.goc#648