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