nvp

package
v0.0.0-...-326b91d Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

Package nvp provides helper functions for any KeyValuePair, which satisfies the K/V/GetV = Key/Value interface.

TODO: support other popular naming conventions, e.g.

Key Value
Id Is

Some functions help to utilise the recursive nature of an arbitrary KeyValuePair.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Leaf

func Leaf(p KeyValuePair) interface{}

Leaf returns a new TagAny named "key" and containing d

func NamePath

func NamePath(p KeyValuePair) string

NamePath returns the names leading to the hidden treasure as a "path"

Note: as the "path" is cleaned, it may not lead You back to the treasure!

func NameS

func NameS(p KeyValuePair) []string

NameS returns the names leading to the hidden treasure as a slice of strings

Types

type Friendly

type Friendly interface {
	NamePath() string                // return the names leading to the hidden treasure as a (cleaned!) "path"
	Leaf(p KeyValuePair) interface{} // return the treasure hidden deep inside KeyValuePair's
	NameS() []string                 // return the names leading to the hidden treasure as a slice of strings
}

Friendly - my interface - exposed for godoc - only ;-)

Note: You may like to use my own kind as stuff ;-)

Thus: build a path to where I hide - KeyValuePairly!
just: Using Named() in a loop may not get You much :-(
just the same name over and over ... and over again ...
thus: better use me.Into(key string) to build Your path ;-)

How to use? Easy:

Use Into to hide the treasure under another name
Use Leaf to retrieve the treasure
Use NameS or Path - they'll tell You where the treasure is hidden
... just in case You forgot ;-)

type KeyValuePair

type KeyValuePair interface {
	K() string
	V() string
	GetV() interface{}
}

KeyValuePair - this interface allows me to recurse Note: this interface is exposed for godoc - only ;-)

Jump to

Keyboard shortcuts

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