Documentation ¶
Index ¶
- Constants
- func BoolPoint(b bool) *bool
- func Contains(arry []string, val string) (index int, flag bool)
- func ConvertFlatMapToArray(flatMap map[string]interface{}, connector string) (outArray []string)
- func ConvertMapToJSONString(inputMap map[string]interface{}) string
- func ConvertRequestBodyByAttr(inputString string, connector string) (outArray []string, err error)
- func ConvertStringToInt(mystring string) int
- func ConvertStructToMap(s interface{}) map[string]interface{}
- func ConvertStructToString(s interface{}) string
- func Dig(object interface{}, keys []interface{}) interface{}
- func DigArray(object interface{}, keys ...interface{}) []interface{}
- func DigBool(object interface{}, keys ...interface{}) bool
- func DigByConnector(object interface{}, key string) interface{}
- func DigFloat(object interface{}, keys ...interface{}) float64
- func DigInt(object interface{}, keys ...interface{}) int
- func DigObject(object interface{}, keys ...interface{}) interface{}
- func DigString(object interface{}, keys ...interface{}) string
- func DigStringArray(object interface{}, keys ...interface{}) []string
- func EndsWith(st string, substring string) (flag bool)
- func FlatDetails(input []interface{}, connector string) map[string]interface{}
- func FlatInitialMap(inputMap map[string]interface{}, connector string) map[string]interface{}
- func FlatInterface(input []interface{}, outputMap map[string]interface{}, key string, ...)
- func FlatMap(inputMap map[string]interface{}, outputMap map[string]interface{}, key string, ...)
- func IsInMap(inputMap map[string]interface{}, key string) bool
- func IsSorted(arry []string, mode string) (flag bool)
- func Join(s ...string) string
- func LookUpKey(sourceMap interface{}, key interface{}) (result interface{})
- func LookUpKeys(sourceMap interface{}, keys ...interface{}) (result interface{})
- func Lstrip(st string, substring string) string
- func MapStructure(m map[string]interface{}, i interface{}) error
- func Max(a int, b int) int
- func Min(a int, b int) int
- func MixCases(s string) string
- func NegateBoolToString(value bool) string
- func NewRand() *rand.Rand
- func Parse(data []byte) map[string]interface{}
- func Rstrip(st string, substring string) string
- func RunCMD(cmd string) (stdout string, stderr string, err error)
- func StartsWith(st string, substring string) (flag bool)
- func Strip(st string, substring string) string
- func Template(source string, args ...interface{}) string
Constants ¶
const ( UnderscoreConnector string = "_" DotConnector string = "." HyphenConnector string = "-" )
Variables ¶
This section is empty.
Functions ¶
func Contains ¶ added in v1.3.0
Contains will return bool balue that whether the arry contains string val
func ConvertFlatMapToArray ¶ added in v1.3.0
ConvertFlatMapToArray will return the request body converted from flatmap {"id":"xxx", "product.id":"xxxx", "managed":true} will be converted to ["{"id":"xxxx"}","{"product":{"id":"xxxx"}}",...]
func ConvertMapToJSONString ¶ added in v1.3.0
ConvertMapToJSONString converts the map to a json string.
func ConvertRequestBodyByAttr ¶ added in v1.3.0
ConvertRequestBodyByAttr will return the request bodies by attributes
func ConvertStringToInt ¶ added in v1.3.0
func ConvertStructToMap ¶ added in v1.3.0
func ConvertStructToMap(s interface{}) map[string]interface{}
func ConvertStructToString ¶ added in v1.3.0
func ConvertStructToString(s interface{}) string
func Dig ¶ added in v1.3.0
func Dig(object interface{}, keys []interface{}) interface{}
Dig Expose dig to used by others
func DigArray ¶ added in v1.3.0
func DigArray(object interface{}, keys ...interface{}) []interface{}
DigArray tries to find an array inside the given object with the given path, and returns its value. If there is no attribute with the given path then the test will be aborted with an error.
func DigBool ¶ added in v1.3.0
func DigBool(object interface{}, keys ...interface{}) bool
DigBool tries to find an attribute inside the given object with the given path, and returns its value, assuming that it is a boolean. For example, if the object is the result of parsing the following JSON document:
{ "kind": "Cluster", "id": "123", "hasId": true, "flavour": { "kind": "Flavour", "hasId": false, "href": "/api/clusters_mgmt/v1/flavours/456" } }
The the 'hasId' attribute can be obtained like this:
hasID := DigBool(object, "hasId")
And the 'hasId' attribute inside the 'flavour' can be obtained like this:
flavourHasID := DigBool(object, "flavour", "hasId")
If there is no attribute with the given path then the return value will be false.
func DigByConnector ¶ added in v1.3.0
func DigByConnector(object interface{}, key string) interface{}
func DigFloat ¶ added in v1.3.0
func DigFloat(object interface{}, keys ...interface{}) float64
DigFloat tries to find an attribute inside the given object with the given path, and returns its value, assuming that it is an floating point number. If there is no attribute with the given path then the test will be aborted with an error.
func DigInt ¶ added in v1.3.0
func DigInt(object interface{}, keys ...interface{}) int
DigInt tries to find an attribute inside the given object with the given path, and returns its value, assuming that it is an integer. If there is no attribute with the given path then the test will be aborted with an error.
func DigObject ¶ added in v1.3.0
func DigObject(object interface{}, keys ...interface{}) interface{}
DigObject tries to find an attribute inside the given object with the given path, and returns its value. If there is no attribute with the given path then the test will be aborted with an error.
func DigString ¶ added in v1.3.0
func DigString(object interface{}, keys ...interface{}) string
DigString tries to find an attribute inside the given object with the given path, and returns its value, assuming that it is an string. For example, if the object is the result of parsing the following JSON document:
{ "kind": "Cluster", "id": "123", "flavour": { "kind": "Flavour", "id": "456", "href": "/api/clusters_mgmt/v1/flavours/456" } }
The the 'id' attribute can be obtained like this:
clusterID := DigString(object, "id")
And the 'id' attribute inside the 'flavour' can be obtained like this:
flavourID := DigString(object, "flavour", "id")
If there is no attribute with the given path then the return value will be an empty string.
func DigStringArray ¶ added in v1.3.0
func DigStringArray(object interface{}, keys ...interface{}) []string
func EndsWith ¶ added in v1.3.0
EndsWith will return the bool value that whether the st is end with substring
func FlatDetails ¶ added in v1.3.0
FlatInitialMap parses the data to store all the attributes at the first level.
func FlatInitialMap ¶ added in v1.3.0
FlatInitialMap parses the data to store all the attributes at the first level.
func FlatInterface ¶ added in v1.3.0
func FlatMap ¶ added in v1.3.0
func FlatMap(inputMap map[string]interface{}, outputMap map[string]interface{}, key string, connector string)
FlatMap parses the data, and stores all the attributes and the sub attributes at the same level with the prefix key.
func LookUpKey ¶ added in v1.3.0
func LookUpKey(sourceMap interface{}, key interface{}) (result interface{})
LookUpKey support find a key in a map
func LookUpKeys ¶ added in v1.3.0
func LookUpKeys(sourceMap interface{}, keys ...interface{}) (result interface{})
LookUpKeys support find keys that has not an abosolute path in a map
func MapStructure ¶ added in v1.3.0
MapStructure will map the map to the address of the structre *i
func NegateBoolToString ¶ added in v1.3.0
NegateBoolToString reverts the boolean to its oppositely value as a string.
func Parse ¶ added in v1.3.0
Parse parses the given JSON data and returns a map of strings containing the result.
func StartsWith ¶ added in v1.3.0
StartsWith return bool whether st start with substring
func Template ¶ added in v1.3.0
Template processes the given template using as data the set of name value pairs that are given as arguments. For example, to the following code:
result, err := Template(` { "name": "{{ .Name }}", "flavour": { "id": "{{ .Flavour }}" } } `, "Name", "mycluster", "Flavour", "4", )
Produces the following result:
{ "name": "mycluster", "flavour": { "id": "4" } }
Types ¶
This section is empty.