dao

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteSize

func ByteSize(b any) string

func GetBytes

func GetBytes(s string) []byte

#nosec G103 GetBytes returns a byte pointer without allocation

func GetFieldValue

func GetFieldValue(key string, exprs string, defaultValue ...interface{}) (r any)

func GetString

func GetString(b []byte) string

#nosec G103 GetString returns a string pointer without allocation

func ImmutableString

func ImmutableString(s string) string

ImmutableString copies a string to make it immutable

func SafeBytes

func SafeBytes(b []byte) []byte

SafeBytes copies a slice to make it immutable

func SafeString

func SafeString(s string) string

SafeString copies a string to make it immutable

func UnsafeBytes

func UnsafeBytes(s string) (bs []byte)

#nosec G103 GetBytes returns a byte pointer without allocation

func UnsafeString

func UnsafeString(b []byte) string

#nosec G103 GetString returns a string pointer without allocation

Types

type Kind

type Kind = reflect.Kind

type Pattern

type Pattern string

Pattern is a resource pattern that may contain wildcards and tags.

Pattern("example.resource.>") // Full wild card (>) matches anything that follows
Pattern("example.item.*")     // Wild card (*) matches a single part
Pattern("example.model.$id")  // Tag (starting with $) matches a single part

func (Pattern) IndexWildcard

func (p Pattern) IndexWildcard() int

IndexWildcard returns the index of the first instance of a wild card (*, >, or $tag) in pattern, or -1 if no wildcard is present.

Behavior is undefined for an invalid pattern.

func (Pattern) IsValid

func (p Pattern) IsValid() bool

IsValid returns true if the pattern is valid, otherwise false.

func (Pattern) Matches

func (p Pattern) Matches(s string) bool

Matches tests if the resource name, s, matches the pattern.

The resource name might in itself contain wild cards and tags.

Behavior is undefined for an invalid pattern or an invalid resource name.

func (Pattern) ReplaceTag

func (p Pattern) ReplaceTag(tag string, value string) Pattern

ReplaceTag searches for a given tag (without $) and replaces it with the value.

Behavior is undefined for an invalid pattern.

func (Pattern) ReplaceTags

func (p Pattern) ReplaceTags(m map[string]string) Pattern

ReplaceTags searches for tags and replaces them with the map value for the key matching the tag (without $).

Behavior is undefined for an invalid pattern.

func (Pattern) Values

func (p Pattern) Values(s string) (map[string]string, bool)

Values extracts the tag values from a resource name, s, matching the pattern.

The returned bool flag is true if s matched the pattern, otherwise false with a nil map.

Behavior is undefined for an invalid pattern or an invalid resource name.

type Tokenize

type Tokenize string

Tokenize is a resource Tokenize that may contain wildcards and tags.

Tokenize("example.resource.>") // Full wild card (>) matches anything that follows
Tokenize("example.item.*")     // Wild card (*) matches a single part
Tokenize("example.model.$id")  // Tag (starting with $) matches a single part

func (Tokenize) IndexWildcard

func (p Tokenize) IndexWildcard() int

IndexWildcard returns the index of the first instance of a wild card (*, >, or $tag) in Tokenize, or -1 if no wildcard is present.

Behavior is undefined for an invalid Tokenize.

func (Tokenize) IsValid

func (p Tokenize) IsValid() bool

IsValid returns true if the Tokenize is valid, otherwise false.

func (Tokenize) Matches

func (p Tokenize) Matches(s string) bool

Matches tests if the resource name, s, matches the Tokenize.

The resource name might in itself contain wild cards and tags.

Behavior is undefined for an invalid Tokenize or an invalid resource name.

func (Tokenize) ReplaceTag

func (p Tokenize) ReplaceTag(tag string, value string) Tokenize

ReplaceTag searches for a given tag (without $) and replaces it with the value.

Behavior is undefined for an invalid Tokenize.

func (Tokenize) ReplaceTags

func (p Tokenize) ReplaceTags(m map[string]string) Tokenize

ReplaceTags searches for tags and replaces them with the map value for the key matching the tag (without $).

Behavior is undefined for an invalid Tokenize.

func (Tokenize) Trim

func (p Tokenize) Trim(s string) Tokenize

func (Tokenize) Values

func (p Tokenize) Values(s string) (map[string]string, bool)

Values extracts the tag values from a resource name, s, matching the Tokenize.

The returned bool flag is true if s matched the Tokenize, otherwise false with a nil map.

Behavior is undefined for an invalid Tokenize or an invalid resource name.

type Type

type Type = reflect.Type

type Value

type Value[T any] struct {
	Val any
}

func (Value[T]) As

func (v Value[T]) As(v2 any)

func (Value[T]) GetType

func (v Value[T]) GetType() string

func (Value[T]) ToBool

func (v Value[T]) ToBool() bool

func (Value[T]) ToBytes

func (v Value[T]) ToBytes() BytesValue

func (Value[T]) ToFloat

func (v Value[T]) ToFloat() float64

func (Value[T]) ToInt

func (v Value[T]) ToInt() int

func (Value[T]) ToString

func (v Value[T]) ToString() string

func (Value[T]) Type

func (v Value[T]) Type() (r Type)

Jump to

Keyboard shortcuts

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