forked from mgutz/logxi
/
util.go
55 lines (49 loc) · 959 Bytes
/
util.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 log
import (
"path/filepath"
"strings"
)
func expandTabs(s string, tabLen int) string {
if s == "" {
return s
}
parts := strings.Split(s, "\t")
buf := pool.Get()
defer pool.Put(buf)
for _, part := range parts {
buf.WriteString(part)
buf.WriteString(strings.Repeat(" ", tabLen-len(part)%tabLen))
}
return buf.String()
}
func maxInt(a, b int) int {
if a > b {
return a
}
return b
}
func minInt(a, b int) int {
if a < b {
return a
}
return b
}
func indexOfNonSpace(s string) int {
if s == "" {
return -1
}
for i, r := range s {
if r != ' ' {
return i
}
}
return -1
}
var inLogxiPath = filepath.Join("AlbinoGeek", "logxi")
var inLogxiPathMod = filepath.Join("!albino!geek", "logxi@v0.0.0")
func isLogxiCode(filename string) bool {
// need to see errors in tests
return (strings.Contains(filename, inLogxiPath) ||
strings.Contains(filename, inLogxiPathMod)) &&
!strings.HasSuffix(filename, "_test.go")
}