types

package
v0.139.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 162

Documentation

Overview

Package types contains types shared between packages in Hugo.

Package types contains types shared between packages in Hugo.

Index

Constants

This section is empty.

Variables

View Source
var InvocationCounter atomic.Int64

This is only used for debugging purposes.

Functions

func IsNil added in v0.55.0

func IsNil(v any) bool

IsNil reports whether v is nil.

func NewBool added in v0.123.0

func NewBool(b bool) *bool

NewTrue returns a pointer to b.

func ToDuration added in v0.85.0

func ToDuration(v any) time.Duration

ToDuration converts v to time.Duration. See ToDurationE if you need to handle errors.

func ToDurationE added in v0.85.0

func ToDurationE(v any) (time.Duration, error)

ToDurationE converts v to time.Duration.

func ToString added in v0.67.1

func ToString(v any) string

ToString converts v to a string.

func ToStringE added in v0.74.0

func ToStringE(v any) (string, error)

ToStringE converts v to a string.

func ToStringSlicePreserveString added in v0.65.0

func ToStringSlicePreserveString(v any) []string

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

func ToStringSlicePreserveStringE added in v0.84.0

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 added in v0.67.1

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 added in v0.124.0

func Unwrapv(v any) any

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

Types

type CloseAdder added in v0.127.0

type CloseAdder interface {
	Add(Closer)
}

type Closer added in v0.127.0

type Closer interface {
	Close() error
}

type Closers added in v0.127.0

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

func (*Closers) Add added in v0.127.0

func (cs *Closers) Add(c Closer)

func (*Closers) Close added in v0.127.0

func (cs *Closers) Close() error

type DevMarker added in v0.55.0

type DevMarker interface {
	DevOnly()
}

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

type EvictingStringQueue added in v0.30.1

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

EvictingStringQueue is a queue which automatically evicts elements from the head of the queue when attempting to add new elements onto the queue and it is full. This queue orders elements LIFO (last-in-first-out). It throws away duplicates. Note: This queue currently does not contain any remove (poll etc.) methods.

func NewEvictingStringQueue added in v0.30.1

func NewEvictingStringQueue(size int) *EvictingStringQueue

NewEvictingStringQueue creates a new queue with the given size.

func (*EvictingStringQueue) Add added in v0.30.1

Add adds a new string to the tail of the queue if it's not already there.

func (*EvictingStringQueue) Contains added in v0.54.0

func (q *EvictingStringQueue) Contains(v string) bool

Contains returns whether the queue contains v.

func (*EvictingStringQueue) Len added in v0.123.0

func (q *EvictingStringQueue) Len() int

func (*EvictingStringQueue) Peek added in v0.30.1

func (q *EvictingStringQueue) Peek() string

Peek looks at the last element added to the queue.

func (*EvictingStringQueue) PeekAll added in v0.30.1

func (q *EvictingStringQueue) PeekAll() []string

PeekAll looks at all the elements in the queue, with the newest first.

func (*EvictingStringQueue) PeekAllSet added in v0.30.1

func (q *EvictingStringQueue) PeekAllSet() map[string]bool

PeekAllSet returns PeekAll as a set.

type KeyValue added in v0.83.0

type KeyValue struct {
	Key   any
	Value any
}

KeyValue is a interface{} tuple.

type KeyValueStr added in v0.38.1

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 NewKeyValuesStrings

func NewKeyValuesStrings(key string, values ...string) KeyValues

NewKeyValuesStrings takes a given key and slice of values and returns a new KeyValues struct.

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 added in v0.123.0

type LowHigh[S ~[]byte | string] struct {
	Low  int
	High int
}

LowHigh represents a byte or slice boundary.

func (LowHigh[S]) IsZero added in v0.134.0

func (l LowHigh[S]) IsZero() bool

func (LowHigh[S]) Value added in v0.134.0

func (l LowHigh[S]) Value(source S) S

type PrintableValueProvider added in v0.132.0

type PrintableValueProvider interface {
	PrintableValue() any
}

PrintableValueProvider is implemented by types that can provide a printable value.

type RLocker added in v0.63.0

type RLocker interface {
	RLock()
	RUnlock()
}

RLocker represents the read locks in sync.RWMutex.

type Result added in v0.132.0

type Result[T any] struct {
	// The result value.
	Value T

	// The error value.
	Err error
}

Result is a generic result type.

func (Result[T]) PrintableValue added in v0.132.0

func (r Result[T]) PrintableValue() any

PrintableValue returns the value or panics if there is an error.

type Unwrapper added in v0.123.0

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 added in v0.55.0

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