go: move to Err* constants

This also replaces most of the 'corrupt document' errors behind a
generic 'ErrCorrupt', which can be inspected to find out exactly which
internal constraint was violated.