Truncate returns the first n runes of s.
(s string, n int)
| 206 | |
| 207 | // Truncate returns the first n runes of s. |
| 208 | func truncateText(s string, n int) string { |
| 209 | truncatedPrefix := "... (truncated)" |
| 210 | n -= len(truncatedPrefix) |
| 211 | |
| 212 | if len(s) <= n { |
| 213 | return s |
| 214 | } |
| 215 | for i := range s { |
| 216 | if n == 0 { |
| 217 | return s[:i] + truncatedPrefix |
| 218 | } |
| 219 | n-- |
| 220 | } |
| 221 | return s |
| 222 | } |
| 223 | |
| 224 | func SummaryTable(req *ExecutionRequest, opts ...RenderOpt) (string, error) { |
| 225 | renderer, err := newRenderer(opts...) |