slices

package
v0.0.0-...-8b9373c Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayColumn

func ArrayColumn(input []interface{}, key string) []interface{}

ArrayColumn Eg: input:[struct{Name:"a",Age:10},{Name:"b",Age:15}] key:"Name" => ["a","b"] input:[map{"k1":"v1","k2":"v2"},map{"k1":"vv1","k2":"vv2"}] key:"k1" => ["v1","vv1"]

func SliceToMapWithColumnAsKey

func SliceToMapWithColumnAsKey(slice interface{}, key string) map[interface{}]interface{}

SliceToMapWithColumnAsKey converts slice type variable `slice` to `map[interface{}]interface{}` The value of specified column use as the key for returned map. Eg: SliceToMapWithColumnAsKey([{"K1": "v1", "K2": 1}, {"K1": "v2", "K2": 2}], "K1") => {"v1": {"K1": "v1", "K2": 1}, "v2": {"K1": "v2", "K2": 2}} SliceToMapWithColumnAsKey([{"K1": "v1", "K2": 1}, {"K1": "v2", "K2": 2}], "K2") => {1: {"K1": "v1", "K2": 1}, 2: {"K1": "v2", "K2": 2}}

Types

This section is empty.

Jump to

Keyboard shortcuts

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