FormatSingleResult 格式化单个检测结果
(result *types.DetectionResult)
| 22 | |
| 23 | // FormatSingleResult 格式化单个检测结果 |
| 24 | func (f *Formatter) FormatSingleResult(result *types.DetectionResult) string { |
| 25 | var output strings.Builder |
| 26 | |
| 27 | // 使用表格格式化器,和批量检测保持一致的格式 |
| 28 | tableFormatter := NewTableFormatter(f.config) |
| 29 | |
| 30 | // 显示域名检测结果表格(无论适合与否) |
| 31 | output.WriteString("检测结果:\n\n") |
| 32 | output.WriteString(tableFormatter.FormatSuitableTable([]*types.DetectionResult{result})) |
| 33 | output.WriteString("\n") |
| 34 | |
| 35 | // 如果不适合,显示不适合的原因 |
| 36 | if !result.Suitable || result.Error != nil { |
| 37 | var unsuitableResults []*types.DetectionResult |
| 38 | unsuitableResults = append(unsuitableResults, result) |
| 39 | output.WriteString(tableFormatter.FormatUnsuitableSummary(unsuitableResults)) |
| 40 | } |
| 41 | |
| 42 | return output.String() |
| 43 | } |
| 44 | |
| 45 | // FormatBatchResult 格式化批量检测结果 |
| 46 | func (f *Formatter) FormatBatchResult(results []*types.DetectionResult, totalDuration time.Duration) string { |
no test coverage detected