2020-04-03 23:11:33 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"regexp"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// ErrTimeoutReached error thrown when a timeout is reached.
|
2020-04-03 23:11:33 +00:00
|
|
|
var ErrTimeoutReached = errors.New("timeout reached")
|
|
|
|
var parseDurationRegexp = regexp.MustCompile(`^(?P<Duration>[1-9]\d*?)(?P<Unit>[smhdwMy])?$`)
|
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Hour is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Hour = time.Minute * 60
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Day is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Day = Hour * 24
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Week is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Week = Day * 7
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Year is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Year = Day * 365
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Month is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Month = Year / 12
|
2020-05-02 16:20:40 +00:00
|
|
|
|
2020-05-04 19:39:25 +00:00
|
|
|
// RFC3339Zero is the default value for time.Time.Unix().
|
|
|
|
const RFC3339Zero = int64(-62135596800)
|
|
|
|
|
2020-05-02 16:20:40 +00:00
|
|
|
const testStringInput = "abcdefghijkl"
|
2020-08-21 02:16:23 +00:00
|
|
|
|
|
|
|
// AlphaNumericCharacters are literally just valid alphanumeric chars.
|
|
|
|
var AlphaNumericCharacters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
2020-12-03 05:23:52 +00:00
|
|
|
|
|
|
|
// ErrTLSVersionNotSupported returned when an unknown TLS version supplied.
|
|
|
|
var ErrTLSVersionNotSupported = errors.New("supplied TLS version isn't supported")
|
|
|
|
|
|
|
|
// TLS13 is the textual representation of TLS 1.3.
|
|
|
|
const TLS13 = "1.3"
|
|
|
|
|
|
|
|
// TLS12 is the textual representation of TLS 1.2.
|
|
|
|
const TLS12 = "1.2"
|
|
|
|
|
|
|
|
// TLS11 is the textual representation of TLS 1.1.
|
|
|
|
const TLS11 = "1.1"
|
|
|
|
|
|
|
|
// TLS10 is the textual representation of TLS 1.0.
|
|
|
|
const TLS10 = "1.0"
|