conv

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func A1ColumnDecode added in v1.5.0

func A1ColumnDecode(column string) (int, error)

A1ColumnDecode takes in A1 Notation & converts it to an index value

Column A is index 1, limit by int (more than ZZZ)

E.g. C == 3, AC == 29, ABC == 731

https://stackoverflow.com/questions/70806630/convert-index-to-column-a1-notation-and-vice-versa

func A1ColumnEncode added in v1.5.0

func A1ColumnEncode(index int) (string, error)

A1ColumnEncode takes in an index value & converts it to A1 Notation

Index 1 is Column A, limit to ZZZ

E.g. 3 == C, 29 == AC, 731 == ABC

func GetItem

func GetItem[T any](obj any, keys string, sep string) (T, error)

GetItem return generic type of specified keys. Allow only map[string]any/[]any parent. Faster but not flexible as GetItem2

func GetItem2 added in v1.4.0

func GetItem2[T any](obj any, keys string, sep string) (out T, err error)

func GetItems added in v1.4.0

func GetItems(obj any, keys string, opts ...Option) []any

GetItems return generic type of specified keys.

. for key separator

#k for key listing

#v or # for value listing

^ prefix for regular expression matching, use DotAlternative for dot.

Example: "path1.path2.items.#.^value_" to access keys, path1 > path2 > items (array) > each item > ^value_ = value of key that starts with "value_"

Example2: "path1.path2.#k" to access keys, path1 > path2 > list keys in part2 object.

func Ternary

func Ternary[T any](b bool, vt T, vf T) T

func To

func To[T any](obj any) (out T, err error)

func ToForce

func ToForce[T any](obj any) (out T)

Types

type Option added in v1.4.0

type Option string
const (
	DotAlternative        = "․"
	OptOmitNoValue Option = "omit no value" //We ignore undefined if exists such as javascript, in go completely ignore null
)

Jump to

Keyboard shortcuts

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