/
const.go
137 lines (113 loc) · 3.17 KB
/
const.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package utils
import (
"errors"
"regexp"
"strings"
"time"
)
const (
// RFC3339Zero is the default value for time.Time.Unix().
RFC3339Zero = int64(-62135596800)
clean = "clean"
tagged = "tagged"
unknown = "unknown"
)
const (
period = "."
https = "https"
wss = "wss"
)
// X.509 consts.
const (
BlockTypeRSAPrivateKey = "RSA PRIVATE KEY"
BlockTypeRSAPublicKey = "RSA PUBLIC KEY"
BlockTypeECDSAPrivateKey = "EC PRIVATE KEY"
BlockTypePKCS8PrivateKey = "PRIVATE KEY"
BlockTypePKIXPublicKey = "PUBLIC KEY"
BlockTypeCertificate = "CERTIFICATE"
BlockTypeCertificateRequest = "CERTIFICATE REQUEST"
BlockTypeX509CRL = "X509 CRL"
KeyAlgorithmRSA = "RSA"
KeyAlgorithmECDSA = "ECDSA"
KeyAlgorithmEd25519 = "ED25519"
HashAlgorithmSHA1 = "SHA1"
HashAlgorithmSHA256 = "SHA256"
HashAlgorithmSHA384 = "SHA384"
HashAlgorithmSHA512 = "SHA512"
EllipticCurveP224 = "P224"
EllipticCurveP256 = "P256"
EllipticCurveP384 = "P384"
EllipticCurveP521 = "P521"
EllipticCurveAltP224 = "P-224"
EllipticCurveAltP256 = "P-256"
EllipticCurveAltP384 = "P-384"
EllipticCurveAltP521 = "P-521"
)
const (
// Hour is an int based representation of the time unit.
Hour = time.Minute * 60
// Day is an int based representation of the time unit.
Day = Hour * 24
// Week is an int based representation of the time unit.
Week = Day * 7
// Year is an int based representation of the time unit.
Year = Day * 365
// Month is an int based representation of the time unit.
Month = Year / 12
)
var (
// StandardTimeLayouts is the set of standard time layouts used with ParseTimeString.
StandardTimeLayouts = []string{
"Jan 2 15:04:05 2006",
time.DateTime,
time.RFC3339,
time.RFC1123Z,
time.RubyDate,
time.ANSIC,
time.DateOnly,
}
standardDurationUnits = []string{"ns", "us", "µs", "μs", "ms", "s", "m", "h"}
reOnlyNumeric = regexp.MustCompile(`^\d+$`)
reDurationStandard = regexp.MustCompile(`(?P<Duration>[1-9]\d*?)(?P<Unit>[^\d\s]+)`)
reNumeric = regexp.MustCompile(`\d+`)
)
// Duration unit types.
const (
DurationUnitDays = "d"
DurationUnitWeeks = "w"
DurationUnitMonths = "M"
DurationUnitYears = "y"
)
// Number of hours in particular measurements of time.
const (
HoursInDay = 24
HoursInWeek = HoursInDay * 7
HoursInMonth = HoursInDay * 30
HoursInYear = HoursInDay * 365
)
const (
// timeUnixEpochAsMicrosoftNTEpoch represents the unix epoch as a Microsoft NT Epoch.
// The Microsoft NT Epoch is ticks since Jan 1, 1601 (1 tick is 100ns).
timeUnixEpochAsMicrosoftNTEpoch uint64 = 116444736000000000
)
var htmlEscaper = strings.NewReplacer(
"&", "&",
"<", "<",
">", ">",
`"`, """,
"'", "'",
)
// ErrTimeoutReached error thrown when a timeout is reached.
var ErrTimeoutReached = errors.New("timeout reached")
const (
windows = "windows"
errFmtLinuxNotFound = "%s %%s: no such file or directory"
errFmtWindowsNotFound = "%s %%s: The system cannot find the %s specified."
strStat = "stat"
strOpen = "open"
strFile = "file"
strPath = "path"
strIsDir = "isdir"
strPathNotFound = "pathnotfound"
strFileNotFound = "filenotfound"
)