common

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PathSeparator is the character used to separate the elements
	// of the keypath.
	//
	// For example, `location.address.city`
	PathSeparator = "."

	// SignatureSeparator is the character that is used to
	// separate the Base64 string from the security signature.
	SignatureSeparator = "_"
)

Functions

func CLen added in v0.1.2

func CLen(n []byte) int

CLen gets the C-string length

func CTrim added in v0.1.2

func CTrim(str string) string

CTrim trims a c function

Types

type Map

type Map map[string]interface{}

Map is the standard wrapper around a map[string]interface{}

func (Map) Bool

func (m Map) Bool(key string, def ...bool) bool

Bool parses and returns the boolean value of the parameter

func (Map) Copy

func (m Map) Copy() generic.Map

Copy does a shallow copy

func (Map) Delete

func (m Map) Delete(key interface{})

Delete removes a key

func (Map) DeleteAll

func (m Map) DeleteAll(keys ...interface{})

DeleteAll removes several keys

func (Map) Duration

func (m Map) Duration(key string, def ...time.Duration) time.Duration

Duration returns a duration value

func (Map) Float64

func (m Map) Float64(key string, def ...float64) float64

Float64 returns the float value or 0 if not set

func (Map) ForEach

func (m Map) ForEach(itr func(key, value interface{}))

ForEach iterates over the map

func (Map) Get

func (m Map) Get(key interface{}) generic.Value

Get returns the value and if the key is set

func (Map) GetValue

func (m Map) GetValue(key string) (generic.Value, bool)

GetValue returns a Value and if the key is set

func (Map) Int

func (m Map) Int(key string, def ...int) int

Int returns the int value or 0 if not set

func (Map) Int64

func (m Map) Int64(key string, def ...int64) int64

Int64 returns the int value or 0 if not set

func (Map) IsSet

func (m Map) IsSet(key interface{}) bool

IsSet returns true if the parameter is set

func (Map) Keys

func (m Map) Keys() interface{}

Keys returns the keys from the map

func (Map) Map

func (m Map) Map() map[string]interface{}

Map returns the string map

func (Map) Scan

func (m Map) Scan(value interface{}) error

Scan reads a json value from the database into a Map

func (Map) Set

func (m Map) Set(key, value interface{})

Set sets a value in the map

func (Map) String

func (m Map) String(key string, def ...string) string

String returns a string value for the param, or the optional default

func (Map) StringPtr

func (m Map) StringPtr(key string, def ...string) *string

StringPtr returns a string ptr or nil

func (Map) StringSlice

func (m Map) StringSlice(key string) []string

StringSlice returns a string value for the param, or the optional default

func (Map) Sub

func (m Map) Sub(key interface{}) generic.Map

Sub returns a sub Map for the key

func (Map) Validate

func (m Map) Validate() error

Validate validates this map

func (Map) Value

func (m Map) Value() (driver.Value, error)

Value returns Map as a value that can be stored as json in the database

func (Map) Values

func (m Map) Values() interface{}

Values returns the keys from the map

func (Map) With

func (m Map) With(keys ...interface{}) generic.Map

With returns a map with only the specified keys

func (Map) Without

func (m Map) Without(keys ...interface{}) generic.Map

Without removes the keys, returns a shallow copy

type StringSlice

type StringSlice []string

StringSlice is helper for the common []string

func (StringSlice) Append

func (s StringSlice) Append(vals ...interface{}) generic.Slice

Append returns a slice with the values appended

func (StringSlice) Contains

func (s StringSlice) Contains(values ...interface{}) bool

Contains returns true of the slice contains all of the values

func (StringSlice) ContainsAny

func (s StringSlice) ContainsAny(values ...interface{}) bool

ContainsAny returns true of the slice contains any of the values

func (StringSlice) ContainsAnyPrefix added in v0.1.3

func (s StringSlice) ContainsAnyPrefix(values ...interface{}) bool

ContainsAny returns true of the slice contains any of the values

func (StringSlice) ContainsPrefix added in v0.1.3

func (s StringSlice) ContainsPrefix(values ...interface{}) bool

Contains returns true of the slice contains all of the values

func (StringSlice) Empty added in v0.1.3

func (s StringSlice) Empty() bool

Empty returns true if the slice is empty

func (StringSlice) Filter

func (s StringSlice) Filter(f func(index int, val interface{}) bool) generic.Slice

Filter filters the slice based on the filter method

func (StringSlice) FilterPrefix added in v0.1.2

func (s StringSlice) FilterPrefix(prefix string) StringSlice

FilterPrefix returns the expand list filtered on the prefix

func (StringSlice) ForEach

func (s StringSlice) ForEach(f func(index int, val interface{}))

ForEach iterates over the slice

func (StringSlice) Get

func (s StringSlice) Get(index int) interface{}

Get returns the item at the index

func (StringSlice) IndexOf

func (s StringSlice) IndexOf(val interface{}) int

IndexOf returns the index of the value in the slice, or -1 if not found

func (StringSlice) Insert

func (s StringSlice) Insert(index int, val interface{}) generic.Slice

Insert returns a slice with the value appended at the index

func (StringSlice) Len

func (s StringSlice) Len() int

Len returns the length of the slice

func (StringSlice) Map

func (s StringSlice) Map(out interface{}, filters ...generic.MapFilter)

Map converts the slice to a map

func (StringSlice) Remove

func (s StringSlice) Remove(index int) generic.Slice

Remove returns a slice with the value removed at the index

func (StringSlice) ToMap

func (s StringSlice) ToMap() generic.Map

ToMap converts the slice to an index map

func (StringSlice) Unique added in v0.1.2

func (s StringSlice) Unique() StringSlice

Unique returns a scope withonly unique values

Jump to

Keyboard shortcuts

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