Documentation ¶
Overview ¶
Package utils is the utilities to process internal data of sdk
Index ¶
- Variables
- func CheckStringIn(val string, availables []string) error
- func IsStringIn(val string, availables []string) bool
- func MergeMap(args ...map[string]string) map[string]string
- func SetMapIfNotExists(m map[string]string, k string, v string)
- func ValueAtPath(v interface{}, path string) (interface{}, error)
- type FuncWaiter
- type Patch
- type RegexpPatcher
- type Waiter
Constants ¶
This section is empty.
Variables ¶
var FrequencePatcher = NewRegexpPatcher(`"Frequence":\s?"([\d.]+)"`, `"Frequence": $1`)
FrequencePatcher will convert `Frequence` as float64
var PortPatcher = NewRegexpPatcher(`"Port":\s?"(\d+)"`, `"Port": $1`)
PortPatcher will convert `Port` as integer
var RetCodePatcher = NewRegexpPatcher(`"RetCode":\s?"(\d+)"`, `"RetCode": $1`)
RetCodePatcher will convert `RetCode` as integer
Functions ¶
func CheckStringIn ¶
CheckStringIn will check if the value is contains by an array
func IsStringIn ¶
IsStringIn will return if the value is contains by an array
func SetMapIfNotExists ¶
SetMapIfNotExists will set a key-value of the map if the key is not exists
func ValueAtPath ¶
ValueAtPath will get struct attribute value by recursive
Types ¶
type FuncWaiter ¶
type FuncWaiter struct { Interval time.Duration MaxAttempts int Checker func() (bool, error) IgnoreError bool // contains filtered or unexported fields }
FuncWaiter used for waiting any condition function.
func (*FuncWaiter) Cancel ¶
func (w *FuncWaiter) Cancel() error
Cancel will stop all of WaitForCompletion function call.
func (*FuncWaiter) WaitForCompletion ¶
func (w *FuncWaiter) WaitForCompletion() error
WaitForCompletion will wait until the state of consdition is available. It will call the condition function to ensure state with interval.
type RegexpPatcher ¶
type RegexpPatcher struct {
// contains filtered or unexported fields
}
RegexpPatcher a patch object to provider a converter function from regular expression
func NewRegexpPatcher ¶
func NewRegexpPatcher(regex string, repl string) *RegexpPatcher
NewRegexpPatcher will return a patch object to provider a converter function from regular expression
func (*RegexpPatcher) Patch ¶
func (p *RegexpPatcher) Patch(body []byte) []byte
Patch will convert a bytes to another bytes with patch rules
func (*RegexpPatcher) PatchString ¶ added in v0.6.7
func (p *RegexpPatcher) PatchString(body string) string
PatchString will convert a string to another string with patch rules