Skip to content

Commit

Permalink
Fix the removal of package paths
Browse files Browse the repository at this point in the history
Just trimming at the last / doesn't work, for instance

    map[string]foo/bar

Instead, excise word/ everywhere it appears.
  • Loading branch information
randall77 committed Nov 9, 2017
1 parent b25bc97 commit 7ea1f10
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gocore/dwarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"debug/dwarf"
"fmt"
"os"
"regexp"
"sort"
"strings"

Expand Down Expand Up @@ -356,9 +357,13 @@ func runtimeName(dt dwarf.Type) string {
return s
default:
name := dt.String()
if i := strings.LastIndex(name, "/"); i >= 0 {
name = name[i+1:] // Runtime uses only last name in package path.
// The runtime uses just the package name, not the package path.
// Get rid of the package paths.
r, err := regexp.Compile("\\w+/")
if err != nil {
panic(err)
}
name = strings.Join(r.Split(name, -1), "")
return name
}
}
Expand Down

0 comments on commit 7ea1f10

Please sign in to comment.