Commit c3fa6f4d authored by Hiroshi Ioka's avatar Hiroshi Ioka Committed by Ian Lance Taylor

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

Fixes #21436

Change-Id: I56f43e2852696c28edbcc772a54125a9a9c32497
Reviewed-on: https://go-review.googlesource.com/55262Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 90ffc40e
...@@ -217,3 +217,12 @@ func TestRelocTypeString(t *testing.T) { ...@@ -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") 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")
}
}
...@@ -41,6 +41,16 @@ const ( ...@@ -41,6 +41,16 @@ const (
TypeBundle Type = 8 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. // A Cpu is a Mach-O cpu type.
type Cpu uint32 type Cpu uint32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment