alter

package
v0.0.0-...-e081c89 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alter

func Alter(ctx context.Context, v interface{}, path []string, new interface{}) (interface{}, error)

Alter a data structure. Requires a path (pre-split) and new structure as a JSON string. A more seasoned developer will see plenty of room for optimisation however this function was largely thrown together in a "let's create something that works first and worry about performance later" kind of sense (much like a lot of murex's code base). That being said, I will accept any pull requests from other developers wishing to improve this - or other - functions. I'm also open to any breaking changes those optimisations might bring (at least until the project reaches version 1.0).

func Merge

func Merge(ctx context.Context, v interface{}, path []string, new interface{}) (interface{}, error)

Merge a data structure; like Alter but merges arrays and maps where possible

func SplitPath

func SplitPath(path string) ([]string, error)

SplitPath takes a string with a prefixed delimiter and separates it into a slice of path elements

func StrToInterface

func StrToInterface(s string) interface{}

func Sum

func Sum(ctx context.Context, v interface{}, path []string, new interface{}) (interface{}, error)

Sum a data structure; like Merge but sums values in arrays and maps where duplication exists

Types

This section is empty.

Jump to

Keyboard shortcuts

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