kv

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: GPL-3.0 Imports: 0 Imported by: 0

README

kv

-- import "github.com/thisiserico/golib/kv"

Package kv provides a way to work with keys and values. Those let keep the consistency among packages when working with key-value pairs.

Usage

type Pair
type Pair struct {
	Val
}

Pair encapsulates a key-value representation. All Val methods can be accessed from a Pair.

func BuildID
func BuildID(id string) Pair

BuildID provides a new Pair that encapsulates a build ID.

func CorrelationID
func CorrelationID(id string) Pair

CorrelationID provides a new Pair that encapsulates a correlation ID.

func IsDryRun
func IsDryRun(dryRun bool) Pair

IsDryRun provides a new Pair that encapsulates an is dry run indicator.

func New
func New(key string, val interface{}) Pair

New generates a new Pair using the given key and values.

func NewObfuscated
func NewObfuscated(key string, val interface{}) Pair

NewObfuscated generates a new Pair using the given key. The value, however, will be obfuscated. This prevents situations where a value is not supposed to be reported to other components. Only strings are supported at this time.

func ServiceHost
func ServiceHost(host string) Pair

ServiceHost provides a new Pair that encapsulates a service host.

func ServiceName
func ServiceName(name string) Pair

ServiceName provides a new Pair that encapsulates a service name.

func TriggeredBy
func TriggeredBy(name string) Pair

TriggeredBy provides a new Pair that encapsulates a triggered by value.

func (Pair) Name
func (p Pair) Name() string

Name returns the key name of the Pair.

type Val
type Val struct {
}

Val encapsulates the given value. Keeping it encapsulated allows to work with obfuscated pairs. A value can also be used on its own.

func Value
func Value(v interface{}) Val

Value returns the value of the Pair.

func (Val) Bool
func (v Val) Bool() bool

Bool returns the raw boolean value.

func (Val) Int
func (v Val) Int() int

Int returns the raw integer value.

func (Val) String
func (v Val) String() string

String returns the raw string value. If the value is obfuscated, a redacted value is provided instead.

func (Val) Value
func (v Val) Value() interface{}

Value returns the raw value in its original form. If the value is obfuscated, a redacted value is provided instead.

Documentation

Overview

Package kv provides a way to work with keys and values. Those let keep the consistency among packages when working with key-value pairs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Val
	// contains filtered or unexported fields
}

Pair encapsulates a key-value representation. All Val methods can be accessed from a Pair.

func BuildID

func BuildID(id string) Pair

BuildID provides a new Pair that encapsulates a build ID.

func CorrelationID

func CorrelationID(id string) Pair

CorrelationID provides a new Pair that encapsulates a correlation ID.

func IsDryRun

func IsDryRun(dryRun bool) Pair

IsDryRun provides a new Pair that encapsulates an is dry run indicator.

func New

func New(key string, val interface{}) Pair

New generates a new Pair using the given key and values.

func NewObfuscated

func NewObfuscated(key string, val interface{}) Pair

NewObfuscated generates a new Pair using the given key. The value, however, will be obfuscated. This prevents situations where a value is not supposed to be reported to other components. Only strings are supported at this time.

func ServiceHost

func ServiceHost(host string) Pair

ServiceHost provides a new Pair that encapsulates a service host.

func ServiceName

func ServiceName(name string) Pair

ServiceName provides a new Pair that encapsulates a service name.

func TriggeredBy

func TriggeredBy(name string) Pair

TriggeredBy provides a new Pair that encapsulates a triggered by value.

func (Pair) Name

func (p Pair) Name() string

Name returns the key name of the Pair.

type Val

type Val struct {
	// contains filtered or unexported fields
}

Val encapsulates the given value. Keeping it encapsulated allows to work with obfuscated pairs. A value can also be used on its own.

func Value

func Value(v interface{}) Val

Value returns the value of the Pair.

func (Val) Bool

func (v Val) Bool() bool

Bool returns the raw boolean value.

func (Val) Int

func (v Val) Int() int

Int returns the raw integer value.

func (Val) String

func (v Val) String() string

String returns the raw string value. If the value is obfuscated, a redacted value is provided instead.

func (Val) Value

func (v Val) Value() interface{}

Value returns the raw value in its original form. If the value is obfuscated, a redacted value is provided instead.

Jump to

Keyboard shortcuts

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