Documentation ¶
Overview ¶
array package hold all functions related to array type
Index ¶
- func AddInt32IfNotExists(arr []int, str int) []int
- func AddIntIfNotExists(arr []int, str int) []int
- func AddStringIfNotExists(arr []string, str string) []string
- func Int32Contains(arr []int, str int) bool
- func IntContains(arr []int, str int) bool
- func IsFloatExist(slice []float64, val float64) bool
- func SliceAppendIfNotExists(in, out []string) []string
- func StringContains(arr []string, str string) bool
- func StringJoin(arr []string, sep string) string
- func StringToInt(arr []string) []int64
- func ToJson(arr []interface{}) (string, error)
- type A
- type MSX
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddInt32IfNotExists ¶
AddInt32IfNotExists add int32 value into slice of int32 if it is not exist a := []int{1, 4} m1 := array.AddInt32IfNotExists(a, 3) // [1, 3, 4]
func AddIntIfNotExists ¶
AddIntIfNotExists add int value into slice of int if it is not exist a := []int{1, 4} m1 := array.AddIntIfNotExists(a, 3) // [1, 3, 4]
func AddStringIfNotExists ¶
AddStringIfNotExists add string value into slice of string if it is not exist a := []string{"aku", "rcti"} m1 := array.AddStringIfNotExists(a, "plus") // ["aku", "rcti", "plus"]
func Int32Contains ¶
Int32Contains check in array of int32 for a value a := []int32{1, 2} m1 := array.Int32Contains(a, 2) // true
func IntContains ¶
IntContains check in array of int for a value a := []int{1, 2} m1 := array.IntContains(a, 2) // true
func IsFloatExist ¶
IsFloatExist check if value (float) exists in array a := []string{3,14, 1,2} m1 := array.IsFloatExist(a, 2,15) // false m2 := array.IsFloatExist(a, 1,2) // true
func SliceAppendIfNotExists ¶
SliceAppendIfNotExists append slice of string from other slice if it is not exist a := []string{"my","name"} m1 := array.SliceAppendIfNotExists([]string{"jhon", "doe"}, a) // ["my", "name", "john", "doe"]
func StringContains ¶
StringContains check in array of string for a value a := []string{"oke", "not oke"} m1 := array.StringContains(a, "oke") // true
func StringJoin ¶
StringJoin combine strings in the array of string with the chosen string separator
m1:= []string{`satu`,`dua`} array.StringJoin(m1,`-`) // satu-dua
func StringToInt ¶
StringToInt convert string list to integer list
m1:= []int64{123,456} array.IntJoin(m1,`-`) // 123-456