1
0
mirror of https://github.com/golang/go synced 2024-11-24 14:50:13 -07:00

debug/macho: make Type implements fmt.(Go)Stringer interfaces

Fixes #21436

Change-Id: I56f43e2852696c28edbcc772a54125a9a9c32497
Reviewed-on: https://go-review.googlesource.com/55262
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Hiroshi Ioka 2017-08-14 17:26:22 +09:00 committed by Ian Lance Taylor
parent 90ffc40e4f
commit c3fa6f4ddc
2 changed files with 19 additions and 0 deletions

View File

@ -217,3 +217,12 @@ func TestRelocTypeString(t *testing.T) {
t.Errorf("got %v, want %v", X86_64_RELOC_BRANCH.GoString(), "macho.X86_64_RELOC_BRANCH")
}
}
func TestTypeString(t *testing.T) {
if TypeExec.String() != "Exec" {
t.Errorf("got %v, want %v", TypeExec.String(), "Exec")
}
if TypeExec.GoString() != "macho.Exec" {
t.Errorf("got %v, want %v", TypeExec.GoString(), "macho.Exec")
}
}

View File

@ -41,6 +41,16 @@ const (
TypeBundle Type = 8
)
var typeStrings = []intName{
{uint32(TypeObj), "Obj"},
{uint32(TypeExec), "Exec"},
{uint32(TypeDylib), "Dylib"},
{uint32(TypeBundle), "Bundle"},
}
func (t Type) String() string { return stringName(uint32(t), typeStrings, false) }
func (t Type) GoString() string { return stringName(uint32(t), typeStrings, true) }
// A Cpu is a Mach-O cpu type.
type Cpu uint32