(content string, maxChars int)
| 131 | if sizeBytes < 1024*1024 { |
| 132 | return fmt.Sprintf("%.1f KB", float64(sizeBytes)/1024) |
| 133 | } |
| 134 | if sizeBytes < 1024*1024*1024 { |
| 135 | return fmt.Sprintf("%.1f MB", float64(sizeBytes)/(1024*1024)) |
| 136 | } |
| 137 | return fmt.Sprintf("%.2f GB", float64(sizeBytes)/(1024*1024*1024)) |
| 138 | } |
| 139 | |
| 140 | func hardTruncate(content string, maxChars int) string { |
| 141 | if charLen(content) <= maxChars { |
| 142 | return content |
| 143 | } |
| 144 | half := maxChars / 2 |
| 145 | head := firstChars(content, half) |
| 146 | tail := lastChars(content, half) |
| 147 | if maxChars == 0 { |
| 148 | tail = content |
no test coverage detected