Documentation
¶
Index ¶
- Constants
- Variables
- func Checksum(a string) string
- func CreateMnemonic(phrase string) (string, error)
- func ElapsedTimeSince(t time.Time) int64
- func Exists(env string) bool
- func Fingerprint(a string) string
- func GetBool(env string, def bool) bool
- func GetInt(env string, def int64) int64
- func GetString(env, def string) string
- func IncT(t int64, m int) int64
- func Marshal(v interface{}) ([]byte, error)
- func MarshalToString(v interface{}) (string, error)
- func Nano() int64
- func Now() int64
- func RandPasswordString(n int) string
- func RandString() string
- func RandStringId() string
- func RandStringN(n int) string
- func RandStringSimple(n int) string
- func RandomToken(prefix string) (string, error)
- func Seed(seed int64)
- func SetLogLevel()
- func ShortUUID() (string, error)
- func SimpleUUID() (string, error)
- func ToHour(t int64) int
- func ToHourUTC(t int64) int
- func ToUTC(t int64) string
- func ToWeekday(t int64) int
- func UUID() (string, error)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalFromReader(reader io.Reader, v interface{}) error
- func UnmarshalFromString(str string, v interface{}) error
- type AnyType
- type GenericProvider
- type InstanceProviderFunc
- type PlaceholderType
- type Provider
- type ProviderConfig
- type ProviderType
Constants ¶
const ( MsgMissingProvider = "provider '%s' required" MsgUnsupportedProviderType = "unsupported provider type '%d'" )
const (
LOG_LEVEL = "LOG_LEVEL"
)
const (
MinWordsInPassPhrase = 11
)
Variables ¶
var ( // ErrInvalidPassPhrase indicates that the pass phrase is too short ErrInvalidPassPhrase = errors.New("invalid pass phrase") )
Functions ¶
func CreateMnemonic ¶ added in v2.10.0
func ElapsedTimeSince ¶
ElapsedTimeSince returns the difference between t and now.
func Exists ¶
Exists verifies that the environment variable 'env' is defined and returns a non-empty value.
func Fingerprint ¶
Fingerprint creates a unique ID (MD5) from a string
func GetBool ¶ added in v2.5.0
GetBool returns the environment variable ENV['env'] as boolean or def if 'env' is not set.
func GetInt ¶
GetInt returns the environment variable ENV['env'] as an int64 or def if 'env' is not set.
func GetString ¶
GetString returns the environment variable ENV['env'] or def if 'env' is not set. Note: def is only returned if the 'env' is not set, i.e. an EMPTY 'env' is still returned !
func MarshalToString ¶
MarshalToString marshals v into a string.
func RandPasswordString ¶ added in v2.10.0
func RandStringN ¶
RandString returns a random sting of lenght n based on a..zA..z0..9
func RandStringSimple ¶ added in v2.10.0
RandStringSimple returns a random sting of lenght n based on a..z0..9. This is basically the same as RandStringN but only case-insensitive.
func RandomToken ¶
RandomToken generates a random token similar to a to a RFC 4122 UID
func Seed ¶
func Seed(seed int64)
Seed sets the seed for the default random source. This affects all random string generation functions that don't use crypto/rand.
func SetLogLevel ¶ added in v2.5.0
func SetLogLevel()
SetLogLevel configures the global logging level based on the LOG_LEVEL environment variable. Supported values are: "trace", "debug", "info", "warn", "error". If the value is not recognized or not set, logging will be disabled.
func SimpleUUID ¶
SimpleUUID generates a random UUID according to RFC 4122, without any dashes
func UnmarshalFromReader ¶
UnmarshalFromReader unmarshals v from reader.
func UnmarshalFromString ¶
UnmarshalFromString unmarshals v from str.
Types ¶
type GenericProvider ¶ added in v2.10.0
type GenericProvider interface {
Close() error
}
type InstanceProviderFunc ¶ added in v2.10.0
type InstanceProviderFunc func() interface{}
type PlaceholderType ¶
type PlaceholderType = struct{}
PlaceholderType represents a placeholder type.
var Placeholder PlaceholderType
Placeholder is a placeholder object that can be used globally.
type Provider ¶ added in v2.10.0
type Provider struct {
// contains filtered or unexported fields
}
func New ¶ added in v2.10.0
func New(opts ...ProviderConfig) (*Provider, error)
New creates a new provider instance and configures it with provider implementations
func (*Provider) Close ¶ added in v2.10.0
Close iterates over all registered ProviderConfigs and asks them to 'close'
func (*Provider) Find ¶ added in v2.10.0
func (p *Provider) Find(providerType ProviderType) (interface{}, bool)
Find returns the registered provider instance if defined. The bool flag is set to true if there is a provider and false otherwise.
func (*Provider) RegisterProviders ¶ added in v2.10.0
func (p *Provider) RegisterProviders(ignoreExists bool, opts ...ProviderConfig) error
RegisterProviders registers one or more providers. An existing provider will be overwritten if ignoreExists is true, otherwise the function returns an error.
type ProviderConfig ¶ added in v2.10.0
type ProviderConfig struct {
ID string
Type ProviderType
Impl InstanceProviderFunc
}
func WithProvider ¶ added in v2.10.0
func WithProvider(ID string, providerType ProviderType, impl InstanceProviderFunc) ProviderConfig
WithProvider returns a populated ProviderConfig struct.
type ProviderType ¶ added in v2.10.0
type ProviderType int