limitLines 限制行数
(output string, maxLines int)
| 587 | |
| 588 | // limitLines 限制行数 |
| 589 | func (tm *FileTaskManager) limitLines(output string, maxLines int) string { |
| 590 | if maxLines <= 0 || output == "" { |
| 591 | return output |
| 592 | } |
| 593 | |
| 594 | lines := strings.Split(output, "\n") |
| 595 | if len(lines) <= maxLines { |
| 596 | return output |
| 597 | } |
| 598 | |
| 599 | return strings.Join(lines[len(lines)-maxLines:], "\n") |
| 600 | } |
| 601 | |
| 602 | // 全局任务管理器实例 |
| 603 | var GlobalTaskManager TaskManager |