inline bytes.Split
Vladimir Bauer
4 years ago
| 87 | 87 | strings.Repeat("=", total-till-1), |
| 88 | 88 | ) |
| 89 | 89 | |
| 90 | got := string(getLastLine(buf.Bytes())) | |
| 90 | got := string(bytes.Split(buf.Bytes(), []byte("\n"))[0]) | |
| 91 | 91 | |
| 92 | 92 | if !strings.Contains(got, wantBar) { |
| 93 | 93 | t.Errorf("Want bar: %q, got bar: %q\n", wantBar, got) |
| 140 | 140 | string(runes[2]), |
| 141 | 141 | string(runes[4]), |
| 142 | 142 | ) |
| 143 | got := string(getLastLine(buf.Bytes())) | |
| 143 | got := string(bytes.Split(buf.Bytes(), []byte("\n"))[0]) | |
| 144 | 144 | |
| 145 | 145 | if !strings.Contains(got, wantBar) { |
| 146 | 146 | t.Errorf("Want bar: %q:%d, got bar: %q:%d\n", wantBar, utf8.RuneCountInString(wantBar), got, utf8.RuneCountInString(got)) |
| 283 | 283 | return "" |
| 284 | 284 | }) |
| 285 | 285 | } |
| 286 | ||
| 287 | func getLastLine(bb []byte) []byte { | |
| 288 | split := bytes.Split(bb, []byte("\n")) | |
| 289 | return split[len(split)-2] | |
| 290 | } | |