(maxWidth int, t string)
| 95 | } |
| 96 | |
| 97 | func truncateMiddle(maxWidth int, t string) string { |
| 98 | if len(t) <= maxWidth { |
| 99 | return t |
| 100 | } |
| 101 | |
| 102 | ellipsis := "..." |
| 103 | if maxWidth < len(ellipsis)+2 { |
| 104 | return t[0:maxWidth] |
| 105 | } |
| 106 | |
| 107 | halfWidth := (maxWidth - len(ellipsis)) / 2 |
| 108 | remainder := (maxWidth - len(ellipsis)) % 2 |
| 109 | return t[0:halfWidth+remainder] + ellipsis + t[len(t)-halfWidth:] |
| 110 | } |
nothing calls this directly
no outgoing calls
no test coverage detected