Programming in Go

Errata

ISBN-10: 0321774639 – ISBN-13: 978-0321774637

Issue Resolution Reporter
Page 10. URL change. The URL for gonow has changed to https://github.com/kisom/GoNow. Gary Scarr
Page 17. Typesetting error. In the console output shown after the first paragraph the last 333 at the bottom should be two spaces to the right. Author
Page 21. Spurious text. The first line of the last paragraph on this page has the text keyword!!struct; this should be deleted. Mikhail Strebkov
Page 40. Tiny typo. In the final paragraph of section 1.6. replace “suppport” with “support”. Ryan Boehning
Page 52. Tiny typo. In the first line replace “lines it it” with “lines it is”. Manuel Kiessling
Page 54. Clarification/correction. Replace the paragraph that begins “On the other hand,” with:
“On the other hand, if the right-hand code snippet didn't have iota, Cyan must be given an explicit value, and Magenta would be set to Cyan's value and Yellow would be set to Magenta's value. So, if Cyan was set to, say 9, then they would all be set to 9. We can use both iota and explicit values. For example, we could set Cyan to iota (so its value will be 0), give no value to Magenta (so it becomes 1 due to Cyan's iota), and Yellow to 5. If we then added Black it would have the previous constant's value (i.e., Yellow's 5), unless we gave it an explicit value.”
Luca Boasso
Page 55. Wrong word. In this page's first paragraph replace the phrase “Go's bitwise flags” with “Go's bitwise operators”. Luca Boasso
Page 117. Tiny typo. The function utf.DecodeLastRuneInString() should, of course, be utf8.DecodeLastRuneInString(). Luca Boasso
Page 140. Wrong information. I claimed that Go does copy on write when using augmented assignment with strings, but actually a new string is created under the hood. Replace the phrase “behind the scenes Go must do a copy on write ... was being used”, with “behind the scenes Go must create a new string and copy the original string and the added string into it, which is potentially expensive for large strings.”. Jonathan Amsterdam
Page 142. Wrong value in Figure 4.2 In Figure 4.2 the Value for the statement pi := &y (i.e., the third column's value) should be 22 not y. Darin Greaham
Page 247. Bug. The computeIndent() function will hang if the indent isn't exactly four spaces. To fix this, increment i just before the first return call:
                if char != whitespace {
                    i++ // FIX: will now work for any non-zero indent
                    return strings.Repeat(string(whitespace), i), i
                }
This correction has been made to the indent_sort/indent_sort.go file in the archive files. (Note that the function will fail if the data has no or inconsistent indentation.)
Alexander Häckel
Page 263. Subtle error. In the first paragraph replace the phrase “method's type” with “receiver's type”. Luca Boasso
Page 336. Incorrect phrase. In the penultimate paragraph, replace “is a closure which has captured” with “communicates using the”. Luca Boasso
Pages 341–348. Additional notes. I did some speed testing against an access.log file of 572MB (2.6M lines) on a quad core AMD-64 3GHz machine.
ProgramTimeNotes
apachereport113.8s The file is read in one goroutine which feeds lines to four other goroutines who populate a safe map in its own goroutine.
apachereport213.9s The file is read in one goroutine which feeds lines to four other goroutines who populate a map which is protected by a mutex.
apachereport314.8s The file is read in one goroutine which feeds lines to four other goroutines who populate their own independent maps which are merged as each worker goroutine finishes.
apachereport411.5s The file is read in one goroutine which feeds lines to four other goroutines who populate a safe slice in its own goroutine.
apachereport507.4s Four goroutines each open the same file and read lines from their own quarter of it. They populate their own independent maps which are merged as each worker goroutine finishes. (This example was added after the book was published; it is now included with the book's source code.)
Keen experimenters might like to do their own timings and then create new versions (e.g., apachereport6 based on apachereport1 and apachereport7 based on apachereport2 etc.), but where each goroutine opens the same file and reads in its own lines like apachereport5 does.
Author
Pages 401-416 A small batch of books was printed with one 16-page sheet missing—pages 401-416. Please check that these pages are present if buying in a book store. If you buy online and these pages are missing, you could go through the returns process for a free replacement, or alternatively, download a PDF of the missing pages (2.4MB). I'm very sorry for the inconvenience. Author
Page 439. Missing URL. In the last paragraph, in addition to www.endsoftpatents.org and www.nosoftwarepatents.com, I should have included www.eff.org/patent. Author
Page 439. Update. The European Parliament has now passed into law, European Unitary patents (including software patents). They are due to come into force 2014-01-01. The European patent office will both grant patents and be the final arbiter for disputes (not the European Court of Justice). So Europeans can now expect even worse patent troll shakedowns than those in the U.S. Author.

Book Cover

Top