-
Notifications
You must be signed in to change notification settings - Fork 85
/
package.go
44 lines (36 loc) · 1.02 KB
/
package.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package worker
import (
"fmt"
"io"
"strings"
)
const (
travisFoldStart = "travis_fold:start:%s\r\033[0K"
travisFoldEnd = "travis_fold:end:%s\r\033[0K"
)
func writeFold(w io.Writer, name string, b []byte) (int, error) {
folded := []byte(fmt.Sprintf(travisFoldStart, name))
folded = append(folded, b...)
if string(folded[len(folded)-1]) != "\n" {
folded = append(folded, []byte("\n")...)
}
folded = append(folded, []byte(fmt.Sprintf(travisFoldEnd, name))...)
return w.Write(folded)
}
func writeFoldStart(w io.Writer, name string, b []byte) (int, error) {
folded := []byte(fmt.Sprintf(travisFoldStart, name))
folded = append(folded, b...)
return w.Write(folded)
}
func writeFoldEnd(w io.Writer, name string, b []byte) (int, error) {
folded := b
folded = append(folded, []byte(fmt.Sprintf(travisFoldEnd, name))...)
return w.Write(folded)
}
func stringSplitSpace(s string) []string {
parts := []string{}
for _, part := range strings.Split(s, " ") {
parts = append(parts, strings.TrimSpace(part))
}
return parts
}