formatFuncName tries to extract certain part of the runtime formatted function name to some pre-defined variation. This function is known to not work properly if the package path or name contains a dot.
(v fmtVerb, f string)
| 339 | // This function is known to not work properly if the package path or name |
| 340 | // contains a dot. |
| 341 | func formatFuncName(v fmtVerb, f string) string { |
| 342 | i := strings.LastIndex(f, "/") |
| 343 | j := strings.Index(f[i+1:], ".") |
| 344 | if j < 1 { |
| 345 | return "???" |
| 346 | } |
| 347 | pkg, fun := f[:i+j+1], f[i+j+2:] |
| 348 | switch v { |
| 349 | case fmtVerbLongpkg: |
| 350 | return pkg |
| 351 | case fmtVerbShortpkg: |
| 352 | return path.Base(pkg) |
| 353 | case fmtVerbLongfunc: |
| 354 | return fun |
| 355 | case fmtVerbShortfunc: |
| 356 | i = strings.LastIndex(fun, ".") |
| 357 | return fun[i+1:] |
| 358 | } |
| 359 | panic("unexpected func formatter") |
| 360 | } |
| 361 | |
| 362 | func formatCallpath(calldepth int, depth int) string { |
| 363 | v := "" |
no outgoing calls