The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".
The following errata were submitted by our customers and approved as valid errors by the author or editor.
Version |
Location |
Description |
Submitted By |
Date submitted |
Date corrected |
PDF |
Page 10
last paragraph |
"For example, 1.234, 123.4, 0.00001234, and 12340000 are all floating-point numbers.".
How is 12340000 a floating-point number?
Note from the Author or Editor: Sorry for any confusion. Numeric literals in Go are technically untyped. This is valid go code:
var f float64 = 12340000
So a number with no decimal place is allowed to be assigned to a floating point variable.
|
Jon Forrest |
Nov 01, 2017 |
|
Printed |
Page 12
Last paragraph |
Should read "Hello, " + "World"
NOT
"Hello, " + World"
Note from the Author or Editor: Yes there's a missing double quote character
|
Robert Collins |
May 17, 2017 |
|
PDF |
Page 19
1st paragraph |
"In addition, there two alias types ... "
Should be, "there _are_ two alias types".
|
Caleb St-Denis |
Mar 16, 2019 |
|
PDF |
Page 34
Compiler error message |
This might be cause by that fact that I'm using Go 1.9.2 but the error message I see is
invalid operation: total / len(x) (mismatched types float64 and int)
(Note that is doesn't include the constant '5' that the book shows.)
Note from the Author or Editor: Yes this is likely a change in error messages between Go versions.
|
Jon Forrest |
Nov 01, 2017 |
|
PDF |
Page 48
4th paragraph |
(This is an extremely minor nit).
"One way to use closure" ->
"One way to use a closure"
Note from the Author or Editor: Yes it should be either "a closure" or "closures".
|
Jon Forrest |
Nov 08, 2017 |
|
PDF |
Page 57
1st example in Fields section |
You show
fmt.Println(c.x, c.y, c.r)
c.x = 10
c.y = 5
Shouldn't this be
c.x = 10
c.y = 5
fmt.Println(c.x, c.y, c.r)
Note from the Author or Editor: If memory serves the intention here was merely to demonstrate field access for get and set operations, so the order wasn't intended to be significant, but if changing the order is clearer, then that should be preferred.
|
Jon Forrest |
Nov 09, 2017 |
|
PDF |
Page 61
Chapter 7 |
Creating a Multishape like described:
multiShape := MultiShape {
shapes : [] Shape {
Circle { 0 , 0 , 5 },
Rectangle { 0 , 0 , 10 , 10 },
},
}
spits a compile error:
cannot use Circle literal (type Circle) as type Shape in array or slice literal:
Circle does not implement Shape (area method has pointer receiver)
cannot use Rectangle literal (type Rectangle) as type Shape in array or slice literal:
Rectangle does not implement Shape (area method has pointer receiver)
Note from the Author or Editor: Apologies, the area method for Circle and Rectangle should be non-pointer types:
func (c Circle) area() float64 {
return math.Pi * c.r*c.r
}
func (r Rectangle) area() float64 {
l := distance(r.x1, r.y1, r.x1, r.y2)
w := distance(r.x1, r.y1, r.x2, r.y1)
return l * w
}
Or the literals should be constructed like this:
multiShape := MultiShape{
shapes: []Shape{
&Circle { 0 , 0 , 5 },
&Rectangle { 0 , 0 , 10 , 10 },
},
}
|
Nicholas Crespi |
Nov 16, 2016 |
|
PDF |
Page 66
Penultimate paragraph code example |
Tiny typo:
fmt.Println(strings.Split("a-b-c-d-e", "-")))
Should read:
fmt.Println(strings.Split("a-b-c-d-e", "-"))
|
JC |
Oct 31, 2016 |
|
Printed |
Page 67
4th line |
Two small typos on page 67. The fmt.Println statements have been commented out in the code.
Great book!
Note from the Author or Editor: Confirmed. On page 67, this:
// fmt.Println(strings.ToLower("TEST"))
And this:
// fmt.Println(strings.ToUpper("test"))
Should be uncommented.
|
Anonymous |
Mar 20, 2016 |
|
Printed, PDF |
Page 73
code at the bottom |
The import is missing one package: "io"
On the next page, page 74, there is a line of code :
_, err := io.Copy(h, f)
This will get error if there is no "io" package in the import statement.
The import should be:
import (
"fmt"
"hash/crc32"
"io/ioutil"
"io"
)
Note from the Author or Editor: Yes this is a mistake. "io/ioutil" should be replaced with "io":
package main
import (
"fmt"
"hash/crc32"
"io"
"os"
)
func getHash(filename string) (uint32, error) {
// open the file
f, err := os.Open(filename)
if err != nil {
return 0, err
}
// remember to always close opened files
defer f.Close()
// create a hasher
h := crc32.NewIEEE()
// copy the file into the hasher
// - copy takes (dst, src) and returns (bytesWritten, error)
_, err = io.Copy(h, f)
// we don't care about how many bytes were written, but we do want to
// handle the error
if err != nil {
return 0, err
}
return h.Sum32(), nil
}
func main() {
h1, err := getHash("test1.txt")
if err != nil {
return
}
h2, err := getHash("test2.txt")
if err != nil {
return
}
fmt.Println(h1, h2, h1 == h2)
}
|
Ardya Dipta Nandaviri |
May 07, 2018 |
|
Mobi |
Page 294
Strings |
"Hello, " + World"
=>
"Hello, " + "World"
Note from the Author or Editor: The problem can be found in the Types chapter under the Strings section. (page 12 of the physical book)
|
mkamimura |
Jan 27, 2016 |
|
|
999
Second program listing under "Hashes and Cryptography" in Ch 8 |
As printed (in the Safari Online Book) the second program listed - the one with the getHash function has *several* compile errors with go version go1.5.3 darwin/amd64.
dhassler% go run crc32.go
# command-line-arguments
./crc32.go:6: imported and not used: "io/ioutil"
./crc32.go:11: undefined: os in os.Open
./crc32.go:22: no new variables on left side of :=
./crc32.go:22: undefined: io in io.Copy
I have resolved each to get the example to run but would be interested in the author's solutions - what is the correct version of this example?
Have the examples in the book been tested???
Note from the Author or Editor: The example is indeed broken. A corrected version is here: https://play.golang.org/p/ofZVaifgJG
I made the following changes:
* The imports are:
import (
"fmt"
"io"
"os"
"hash/crc32"
)
* Since `err` was already defined I changed `:=` to `=` for:
_, err = io.Copy(h, f)
|
Dan Hassler |
Jan 25, 2016 |
|