open-vault/vendor/github.com/mitchellh/pointerstructure
Hridoy Roy 4a96126d5a
Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939)
This reverts commit eb74ca61fc4dcb7038f39defb127d5d639ba0ca1.
2021-02-18 15:40:18 -05:00
..
.travis.yml Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
LICENSE Vendor and prep for beta 2019-06-20 23:43:02 -04:00
README.md Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
delete.go Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
get.go Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
go.mod Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
go.sum Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
parse.go Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
pointer.go Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
set.go Revert "Vault Dependency Upgrades [VAULT-871] (#10903)" (#10939) 2021-02-18 15:40:18 -05:00
sort.go Create alias and command for OIDC (#6206) 2019-02-11 13:37:55 -08:00

README.md

pointerstructure GoDoc

pointerstructure is a Go library for identifying a specific value within any Go structure using a string syntax.

pointerstructure is based on JSON Pointer (RFC 6901), but reimplemented for Go.

The goal of pointerstructure is to provide a single, well-known format for addressing a specific value. This can be useful for user provided input on structures, diffs of structures, etc.

Features

  • Get the value for an address

  • Set the value for an address within an existing structure

  • Delete the value at an address

  • Sorting a list of addresses

Installation

Standard go get:

$ go get github.com/mitchellh/pointerstructure

Usage & Example

For usage and examples see the Godoc.

A quick code example is shown below:

complex := map[string]interface{}{
	"alice": 42,
	"bob": []interface{}{
		map[string]interface{}{
			"name": "Bob",
		},
	},
}

value, err := pointerstructure.Get(complex, "/bob/0/name")
if err != nil {
	panic(err)
}

fmt.Printf("%s", value)
// Output:
// Bob

Continuing the example above, you can also set values:

value, err = pointerstructure.Set(complex, "/bob/0/name", "Alice")
if err != nil {
	panic(err)
}

value, err = pointerstructure.Get(complex, "/bob/0/name")
if err != nil {
	panic(err)
}

fmt.Printf("%s", value)
// Output:
// Alice