bellows

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 5 Imported by: 0

README

bellows

Flatten and expand golang maps and structs

Features

There are some existing golang flatten/expand implementations, but they are targeted to specific use-cases, and none of them flatten Structs.

This Flatten will skip parsing a Map that does not have a String as the index.

This Flatten recursively passes values as their original Interface, so it is simpler than implementations that rely on passing reflect.Value.

Usage

// Expand a dot-separated flat map into a nested maps and slices
func Expand(flat map[string]interface{}) interface{}

// Flatten a nested map into a dot-separated flat map
func Flatten(value interface{}) map[string]interface{} {}

// Flatten a nested map into a dot-separated flat map, with a prefix
func FlattenPrefixed(value interface{}, prefix string) map[string]interface{} {}

// Flatten a nested map into an existing dot-separated flat map, with a prefix
func FlattenPrefixedToResult(value interface{}, prefix string, m map[string]interface{}) {}

Other golang flatten/expand implementations

(C) Copyright 2015 doublerebel. MIT Licensed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(flatMap map[string]interface{}, opts ...option) interface{}

func Flatten

func Flatten(value interface{}, opts ...option) map[string]interface{}

func FlattenPrefixedToResult

func FlattenPrefixedToResult(value interface{}, opts *bellowsOptions, m map[string]interface{})

func WithPrefix added in v1.1.0

func WithPrefix(prefix string) option

func WithSep added in v1.1.0

func WithSep(sep string) option

Types

This section is empty.

Jump to

Keyboard shortcuts

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