Use %q instead of %s to print unchecked bytes. Also strip the
"\x00" byte, as "go116ld" reads better than "\x00go116ld".
Change-Id: Id3d1f426ea91d53a55b928dac4a68e1333b80158
Reviewed-on: https://go-review.googlesource.com/c/go/+/315750
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
type ErrGoObjOtherVersion struct{ magic []byte }
func (e ErrGoObjOtherVersion) Error() string {
- return fmt.Sprintf("go object of a different version: %s", e.magic)
+ return fmt.Sprintf("go object of a different version: %q", e.magic)
}
// An objReader is an object file reader.
}
if !bytes.Equal(p, []byte(goobj.Magic)) {
if bytes.HasPrefix(p, []byte("\x00go1")) && bytes.HasSuffix(p, []byte("ld")) {
- return r.error(ErrGoObjOtherVersion{p})
+ return r.error(ErrGoObjOtherVersion{p[1:]}) // strip the \x00 byte
}
return r.error(errCorruptObject)
}