File: util.go

package info (click to toggle)
golang-github-mgutz-logxi 1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 524 kB
  • sloc: makefile: 7
file content (53 lines) | stat: -rw-r--r-- 888 bytes parent folder | download
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
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("mgutz", "logxi", "v"+strings.Split(Version, ".")[0])

func isLogxiCode(filename string) bool {
	// need to see errors in tests
	return strings.HasSuffix(filepath.Dir(filename), inLogxiPath) &&
		!strings.HasSuffix(filename, "_test.go")
}