array

package
v0.0.0-...-06dd36e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

array package hold all functions related to array type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInt32IfNotExists

func AddInt32IfNotExists(arr []int, str int) []int

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

func AddIntIfNotExists(arr []int, str int) []int

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

func AddStringIfNotExists(arr []string, str string) []string

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

func Int32Contains(arr []int, str int) bool

Int32Contains check in array of int32 for a value a := []int32{1, 2} m1 := array.Int32Contains(a, 2) // true

func IntContains

func IntContains(arr []int, str int) bool

IntContains check in array of int for a value a := []int{1, 2} m1 := array.IntContains(a, 2) // true

func IsFloatExist

func IsFloatExist(slice []float64, val float64) bool

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

func SliceAppendIfNotExists(in, out []string) []string

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

func StringContains(arr []string, str string) bool

StringContains check in array of string for a value a := []string{"oke", "not oke"} m1 := array.StringContains(a, "oke") // true

func StringJoin

func StringJoin(arr []string, sep string) string

StringJoin combine strings in the array of string with the chosen string separator

m1:= []string{`satu`,`dua`}
array.StringJoin(m1,`-`) // satu-dua

func StringToInt

func StringToInt(arr []string) []int64

StringToInt convert string list to integer list

m1:= []int64{123,456}
array.IntJoin(m1,`-`) // 123-456

func ToJson

func ToJson(arr []interface{}) (string, error)

ToJson convert map array of string to JSON string type m, err := []interface{}{123,`abc`}

Types

type A

type A []interface{}

array (slice) of anything

v := array.A{}
v = append(v, any_value)

type MSX

type MSX []map[string]interface{}

array (slice) of map with string key and any value

v := array.MSX{}
v = append(v, map[string]{
  `foo`: 123,
  `bar`: `yay`,
})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL