lookup

package
v0.0.0-...-b93a6bd Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package lookup provides functions for (unsafely) looking up values in dynamic maps, structures, etc.

Module is powered by: https://github.com/mcuadros/go-lookup

Note that this package is meant for testing purposes only. On a real application you would avoid unsafe reading of maps and structs as much as possible, and try to use the type system to your advantage.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path(t cbtest.T, i interface{}, path string) interface{}

Path performs a lookup into the given value using a string path. Panics on failure.

Example
m := map[string]interface{}{
	"nested": map[string]interface{}{
		"value": "foo",
	},
}

value := Path(testingT, m, "nested.value")
fmt.Println(value)
Output:

foo

func PathE

func PathE(t cbtest.T, i interface{}, path string) (interface{}, error)

PathE performs a lookup into the given value using a string path. Returns error on failure.

func PathI

func PathI(t cbtest.T, i interface{}, path string) interface{}

PathI performs a lookup into the given value using a case-insensitive string path. Panics on failure.

Example
m := map[string]interface{}{
	"nested": map[string]interface{}{
		"value": "bar",
	},
}

value := PathI(testingT, m, "NESted.VALue")
fmt.Println(value)
Output:

bar

func PathIE

func PathIE(t cbtest.T, i interface{}, path string) (interface{}, error)

PathIE performs a lookup into the given value using a case-insensitive string path. Returns error on failure.

Types

This section is empty.

Jump to

Keyboard shortcuts

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