-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodule.go
101 lines (81 loc) · 2.52 KB
/
module.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// -----------------------------------------------------------------------------
// ZR Library zr/[module.go]
// (c) balarabe@protonmail.com License: MIT
// -----------------------------------------------------------------------------
package zr
import (
"crypto/rand"
"encoding/json"
"fmt"
)
// # Library Version
// VersionTime() string
//
// # String Constants
// # Global Settings
// DebugMode() bool
// SetDebugMode(val bool)
//
// # Module Variables
// -----------------------------------------------------------------------------
// # Library Version
// VersionTime returns the library version as a date/time string.
func VersionTime() string {
// name capitalized to make it easy to locate
versionTime := "2021-02-11 15:21"
return versionTime
} // VersionTime
// -----------------------------------------------------------------------------
// # Global Settings
// DebugMode _ _
func DebugMode() bool {
return debugMode
} // DebugMode
// SetDebugMode _ _
func SetDebugMode(val bool) {
debugMode = val
} // SetDebugMode
// -----------------------------------------------------------------------------
// # Module Variables
var (
// PL is fmt.Println() but is used only for debugging.
PL = fmt.Println
// VL is VerboseLog() but is used only for debugging.
VL = VerboseLog
// debugMode makes the library print verbose output to assist debugging.
debugMode = false
// TabSpace specifies the string to use as a single tab
// (used by GoStringEx() to indent code)
TabSpace = " "
)
// -----------------------------------------------------------------------------
// # Function Proxy Variables (for mocking)
type jsonMod struct {
Unmarshal func([]byte, interface{}) error
}
type randMod struct {
Read func([]byte) (int, error)
}
type thisMod struct {
Error func(args ...interface{}) error
//
// standard library modules:
json jsonMod
rand randMod
}
var mod = thisMod{
Error: Error,
json: jsonMod{
Unmarshal: json.Unmarshal,
},
rand: randMod{
Read: rand.Read,
},
}
// ModReset restores all mocked functions to the original standard functions.
func (ob *thisMod) Reset() {
ob.Error = Error
ob.json.Unmarshal = json.Unmarshal
ob.rand.Read = rand.Read
} // Reset
// end