When MySQL Goes Away

Handling MySQL errors with go-mysql/errors

Handling MySQL errors in Go is not easy. There are a lot of MySQL server error codes, and the Go MySQL driver as its own errors, and Go database/sql has its own errors, and errors can bubble up from other packages, like net.OpError. Consequently, Go programs tend not to handle errors. Instead, they simply report errors: err := db.Query(...).Scan(&v) if err != nil { return err } And then the error is logged or reported somewhere. Read more...