types

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNil

func IsNil(v any) bool

IsNil reports whether v is nil.

func ToString

func ToString(v any) string

ToString converts v to a string.

func ToStringE

func ToStringE(v any) (string, error)

ToStringE converts v to a string.

func ToStringSlicePreserveString

func ToStringSlicePreserveString(v any) []string

ToStringSlicePreserveString is the same as ToStringSlicePreserveStringE, but it never fails.

func ToStringSlicePreserveStringE

func ToStringSlicePreserveStringE(v any) ([]string, error)

ToStringSlicePreserveStringE converts v to a string slice. If v is a string, it will be wrapped in a string slice.

func TypeToString

func TypeToString(v any) (string, bool)

TypeToString converts v to a string if it's a valid string type. Note that this will not try to convert numeric values etc., use ToString for that.

func Unwrapv

func Unwrapv(v any) any

Unwrap returns the underlying value of v if it implements Unwrapper, otherwise v is returned.

Types

type DevMarker

type DevMarker interface {
	DevOnly()
}

DevMarker is a marker interface for types that should only be used during development.

type KeyValueStr

type KeyValueStr struct {
	Key   string
	Value string
}

KeyValueStr is a string tuple.

type KeyValues

type KeyValues struct {
	Key    any
	Values []any
}

KeyValues holds an key and a slice of values.

func (KeyValues) KeyString

func (k KeyValues) KeyString() string

KeyString returns the key as a string, an empty string if conversion fails.

func (KeyValues) String

func (k KeyValues) String() string

type LowHigh

type LowHigh struct {
	Low  int
	High int
}

LowHigh is typically used to represent a slice boundary.

type RLocker

type RLocker interface {
	RLock()
	RUnlock()
}

RLocker represents the read locks in sync.RWMutex.

type Unwrapper

type Unwrapper interface {
	// Unwrapv is for internal use only.
	// It got its slightly odd name to prevent collisions with user types.
	Unwrapv() any
}

Unwrapper is implemented by types that can unwrap themselves.

type Zeroer

type Zeroer interface {
	IsZero() bool
}

Zeroer, as implemented by time.Time, will be used by the truth template funcs in Hugo (if, with, not, and, or).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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