()
| 60 | } |
| 61 | |
| 62 | func (cf *CloudflareIPData) toString() []string { |
| 63 | result := make([]string, 7) |
| 64 | result[0] = cf.IP.String() |
| 65 | result[1] = strconv.Itoa(cf.Sended) |
| 66 | result[2] = strconv.Itoa(cf.Received) |
| 67 | result[3] = strconv.FormatFloat(float64(cf.getLossRate()), 'f', 2, 32) |
| 68 | result[4] = strconv.FormatFloat(cf.Delay.Seconds()*1000, 'f', 2, 32) |
| 69 | result[5] = strconv.FormatFloat(cf.DownloadSpeed/1024/1024, 'f', 2, 32) |
| 70 | // 如果 Colo 为空,则使用 "N/A" 表示 |
| 71 | if cf.Colo == "" { |
| 72 | result[6] = "N/A" |
| 73 | } else { |
| 74 | result[6] = cf.Colo |
| 75 | } |
| 76 | return result |
| 77 | } |
| 78 | |
| 79 | func ExportCsv(data []CloudflareIPData) { |
| 80 | if noOutput() || len(data) == 0 { |
no test coverage detected