-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers_primitive.go
59 lines (45 loc) · 1.29 KB
/
helpers_primitive.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
56
57
58
59
package pprnt
import (
"fmt"
)
const formatString string = "\"%+v\""
const formatInt string = "%d"
const formatBoolean string = "%t"
const formatNil string = "%s"
const formatFloat string = "%+v"
func _PrintString(elem interface{}, key, endChar *string) string {
return _DoPrintPrimitive(formatString, key, endChar, elem)
}
func _PrintInt(elem interface{}, key, endChar *string) string {
return _DoPrintPrimitive(formatInt, key, endChar, elem)
}
func _PrintBoolean(elem interface{}, key, endChar *string) string {
return _DoPrintPrimitive(formatBoolean, key, endChar, elem)
}
func _PrintNil(_ interface{}, key, endChar *string) string {
return _DoPrintPrimitive(formatNil, key, endChar, "<nil>")
}
func _PrintFloat(elem interface{}, key, endChar *string) string {
return _DoPrintPrimitive(formatFloat, key, endChar, elem)
}
func _DoPrintPrimitive(format string, key, endChar *string, elem interface{}) string {
lvlStr := _CreateLevelString()
strToPrint := ""
if key != nil {
strToPrint += lvlStr + "\"" + *key + "\"" + ": "
key = nil
} else {
strToPrint += lvlStr
}
strToPrint += fmt.Sprintf(format, elem)
if _state.Level > 0 {
strToPrint += ","
}
if endChar != nil {
strToPrint += *endChar
} else {
strToPrint += "\n"
}
fmt.Print(strToPrint)
return fmt.Sprint(strToPrint)
}