@@ -76,19 +76,37 @@ type Link struct {
7676
7777// formatError prints a single Links error
7878func (l * Link ) formatError (b []byte ) []byte {
79+ var funcName string
80+
7981 b = append (b , "source=" ... )
8082 idx := strings .LastIndexByte (l .Source .Frame .Function , '.' )
8183 if idx == - 1 {
8284 b = append (b , l .Source .File ()... )
8385 } else {
84- b = append (b , l .Source .Frame .Function [:idx ]... )
86+ funcName = l .Source .Frame .Function [idx + 1 :]
87+ remaining := l .Source .Frame .Function [:idx ]
88+
89+ idx = strings .LastIndexByte (remaining , '/' )
90+ if idx > - 1 {
91+ b = append (b , l .Source .Frame .Function [:idx + 1 ]... )
92+ remaining = l .Source .Frame .Function [idx + 1 :]
93+ }
94+
95+ idx = strings .IndexByte (remaining , '.' )
96+ if idx == - 1 {
97+ b = append (b , remaining ... )
98+ } else {
99+ b = append (b , remaining [:idx ]... )
100+ }
85101 b = append (b , '/' )
86102 b = append (b , l .Source .File ()... )
87103 }
88104 b = append (b , ':' )
89105 b = strconv .AppendInt (b , int64 (l .Source .Line ()), 10 )
90- b = append (b , ':' )
91- b = append (b , l .Source .Frame .Function [idx + 1 :]... )
106+ if funcName != "" {
107+ b = append (b , ':' )
108+ b = append (b , funcName ... )
109+ }
92110 b = append (b , ' ' )
93111 b = append (b , "error=" ... )
94112
0 commit comments