Documentation ¶
Overview ¶
Contains various utility functions.
Index ¶
- Variables
- func Diff(a, b string) string
- func Exists(strs []string, s string) bool
- func PascalCaseToSnakeCase(in string) string
- func Remove(strs []string, s string) []string
- type HasID
- type HasSettings
- type ID
- type IDInterface
- type OnChangeCallback
- type Op
- type ProfToken
- type ProfileEntry
- type ProfileResult
- type Profiler
- type Settings
- func (s *Settings) AddOnChange(key string, cb OnChangeCallback)
- func (s *Settings) Bool(name string, def ...interface{}) bool
- func (s *Settings) ClearOnChange(key string)
- func (s *Settings) Erase(name string)
- func (s *Settings) Get(name string, def ...interface{}) interface{}
- func (s *Settings) Has(name string) bool
- func (s *Settings) Int(name string, def ...interface{}) int
- func (s *Settings) MarshalJSON() (data []byte, err error)
- func (s *Settings) Parent() SettingsInterface
- func (s *Settings) Set(name string, val interface{})
- func (s *Settings) SetParent(p SettingsInterface)
- func (s *Settings) String(name string, def ...interface{}) string
- func (s *Settings) UnmarshalJSON(data []byte) error
- type SettingsInterface
Constants ¶
This section is empty.
Variables ¶
var Prof = Profiler{/* contains filtered or unexported fields */}
Functions ¶
func PascalCaseToSnakeCase ¶
Types ¶
type HasID ¶
type HasID struct {
// contains filtered or unexported fields
}
HasID is an utility struct typically embedded to give the type a unique id
type HasSettings ¶
type HasSettings struct {
// contains filtered or unexported fields
}
HasSettings is an utility struct that is typically embedded in other type structs to make that type implement the SettingsInterface
func (*HasSettings) Settings ¶
func (s *HasSettings) Settings() *Settings
Settings get the settings from HasSettings type
type OnChangeCallback ¶
type OnChangeCallback func(name string)
OnChangeCallback is a func with a parameter name
type Op ¶
type Op int
A comparison operation used in context queries.
const ( OpEqual Op = iota //< Compare for equality. OpNotEqual //< Compare for difference. OpRegexMatch //< Compare for a regular expression match. OpNotRegexMatch //< Compare for a regular expression difference. OpRegexContains //< Compare whether the given regular expression matches some substring of the operand. OpNotRegexContains //< Compare whether the given regular expression does not match some substring of the operand. )
func (*Op) UnmarshalJSON ¶
type ProfileEntry ¶
type ProfileResult ¶
type ProfileResult struct { Name string ProfileEntry }
func (*ProfileResult) Avg ¶
func (v *ProfileResult) Avg() time.Duration
func (ProfileResult) String ¶
func (v ProfileResult) String() string
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
func (*Profiler) Results ¶
func (p *Profiler) Results() (ret []ProfileResult)
func (*Profiler) SortByAvgTime ¶
func (p *Profiler) SortByAvgTime() []ProfileResult
func (*Profiler) SortByName ¶
func (p *Profiler) SortByName() []ProfileResult
func (*Profiler) SortByTotalTime ¶
func (p *Profiler) SortByTotalTime() []ProfileResult
type Settings ¶
type Settings struct { HasID // contains filtered or unexported fields }
Settings is a struct of settings
func (*Settings) AddOnChange ¶
func (s *Settings) AddOnChange(key string, cb OnChangeCallback)
AddOnChange adds a OnChangeCallback identified with the given key. If a callback is already defined for that name, it is overwritten
func (*Settings) ClearOnChange ¶
ClearOnChange removes the OnChangeCallback associated with the given key.
func (*Settings) Erase ¶
Erase erases the setting associated with the given key from this settings object
func (*Settings) Get ¶
Get the setting identified with the given name. An optional default value may be specified. If the setting does not exist in this object, the parent if available will be queried.
func (*Settings) Has ¶
Has returns whether the setting identified by this key exists in this settings object
func (*Settings) MarshalJSON ¶
MarshalJSON settings to data
func (*Settings) Parent ¶
func (s *Settings) Parent() SettingsInterface
Parent returns the parent Settings of this Settings object
func (*Settings) SetParent ¶
func (s *Settings) SetParent(p SettingsInterface)
SetParent sets the parent Settings of this Settings object
func (*Settings) UnmarshalJSON ¶
UnmarshalJSON from data to Settings
type SettingsInterface ¶
type SettingsInterface interface {
Settings() *Settings
}
SettingsInterface defines an interface for types that have settings