-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfos.go
55 lines (51 loc) · 979 Bytes
/
infos.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
45
46
47
48
49
50
51
52
53
54
55
package pretty
import (
"github.com/pierrre/go-libs/strconvio"
"github.com/pierrre/pretty/internal/write"
)
type infos struct {
showLen bool
len int
showCap bool
cap int
showAddr bool
addr uintptr
}
func (i infos) write(st *State) bool {
if !st.ShowInfos {
return false
}
if !i.showLen && !i.showCap && !i.showAddr {
return false
}
w := st.Writer
write.MustString(w, "(")
wrote := false
if i.showLen {
write.MustString(w, "len=")
write.Must(strconvio.WriteInt(w, int64(i.len), 10))
wrote = true
}
if i.showCap {
if wrote {
write.MustString(w, " ")
}
write.MustString(w, "cap=")
write.Must(strconvio.WriteInt(w, int64(i.cap), 10))
wrote = true
}
if i.showAddr {
if wrote {
write.MustString(w, " ")
}
write.MustString(w, "addr=")
writeUintptr(w, i.addr)
}
write.MustString(w, ")")
return true
}
func (i infos) writeWithTrailingSpace(st *State) {
if i.write(st) {
write.MustString(st.Writer, " ")
}
}