-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfmt.go
More file actions
59 lines (46 loc) · 1.33 KB
/
fmt.go
File metadata and controls
59 lines (46 loc) · 1.33 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package berry
import (
"fmt"
"io"
)
// Simple wrap std fmt package
// add SGR parameters to head and tail of out string
// detail of how to use these method, please see fmt package directly
// https://golang.org/pkg/fmt/
func (r R) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
return fmt.Fprintf(w, r.s(format, false), a...)
}
func (r R) Printf(format string, a ...interface{}) (n int, err error) {
return fmt.Printf(r.s(format, false), a...)
}
func (r R) Sprintf(format string, a ...interface{}) string {
return fmt.Sprintf(r.s(format, false), a...)
}
func (r R) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprint(w, r.around(a)...)
}
func (r R) Print(a ...interface{}) (n int, err error) {
return fmt.Print(r.around(a)...)
}
func (r R) Sprint(a ...interface{}) string {
return fmt.Sprint(r.around(a)...)
}
func (r R) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprintln(w, r.around(a)...)
}
func (r R) Println(a ...interface{}) (n int, err error) {
return fmt.Println(r.around(a)...)
}
func (r R) Sprintln(a ...interface{}) string {
return fmt.Sprintln(r.around(a)...)
}
func (r R) around(a []interface{}) []interface{} {
if !enabled {
return a
}
aa := make([]interface{}, len(a)+2)
aa[0] = r.ri
copy(aa[1:], a)
aa[len(a)+1] = tseq
return aa
}