Documentation ¶
Overview ¶
Package idutils provides a set of helper functions to convert ids.
Functions in big_endian_converter.go help converting uint64 ids to TraceID and SpanID using big endian, and vice versa.
Index ¶
- Variables
- func GetLocation(location *string, layout *string) (*time.Location, error)
- func ParseGotime(layout string, value any, location *time.Location) (time.Time, error)
- func ParseLocalizedGotime(layout string, value any, location *time.Location, language string) (time.Time, error)
- func ParseLocalizedStrptime(layout string, value any, location *time.Location, language string) (time.Time, error)
- func ParseStrptime(layout string, value any, location *time.Location) (time.Time, error)
- func SetTimestampYear(t time.Time) time.Time
- func StrptimeToGotime(layout string) (string, error)
- func ValidateGotime(layout string) error
- func ValidateLocale(locale string) error
- func ValidateStrptime(layout string) error
- type PolicyTicker
- type TTicker
Constants ¶
This section is empty.
Variables ¶
var Now = time.Now
Allows tests to override with deterministic value
Functions ¶
func GetLocation ¶ added in v0.80.0
func ParseGotime ¶ added in v0.80.0
func ParseLocalizedGotime ¶ added in v0.110.0
func ParseLocalizedGotime(layout string, value any, location *time.Location, language string) (time.Time, error)
ParseLocalizedGotime is like ParseGotime, but instead of parsing a formatted time in English, it parses a value in foreign language, and returns the time.Time it represents. The language argument must be a well-formed BCP 47 language tag (e.g.: "en", "en-US"), and a known CLDR locale.
func ParseLocalizedStrptime ¶ added in v0.109.0
func ParseLocalizedStrptime(layout string, value any, location *time.Location, language string) (time.Time, error)
ParseLocalizedStrptime is like ParseLocalizedGotime, but instead of using the native Go time layout, it uses the ctime-like format.
func ParseStrptime ¶ added in v0.80.0
func SetTimestampYear ¶ added in v0.80.0
SetTimestampYear sets the year of a timestamp to the current year. This is needed because year is missing from some time formats, such as rfc3164.
func StrptimeToGotime ¶ added in v0.82.0
func ValidateGotime ¶ added in v0.107.0
func ValidateLocale ¶ added in v0.110.0
ValidateLocale checks the given locale and returns an error if the language tag is not supported by the localized parser functions.
func ValidateStrptime ¶ added in v0.107.0
ValidateStrptime checks the given strptime layout and returns an error if it detects any known issues that prevent it from being parsed.
Types ¶
type PolicyTicker ¶
Implements TTicker and abstracts underlying time ticker's functionality to make usage simpler.
func (*PolicyTicker) OnTick ¶
func (pt *PolicyTicker) OnTick()
func (*PolicyTicker) Start ¶
func (pt *PolicyTicker) Start(d time.Duration)
func (*PolicyTicker) Stop ¶
func (pt *PolicyTicker) Stop()
type TTicker ¶
type TTicker interface { // start sets the frequency of the Ticker and starts the periodic calls to OnTick. Start(d time.Duration) // OnTick is called when the Ticker fires. OnTick() // Stop firing the Ticker. Stop() }
TTicker interface allows easier testing of Ticker related functionality