package types
import "github.com/gohugoio/hugo/common/types"
Package types contains types shared between packages in Hugo.
Package types contains types shared between packages in Hugo.
Index ¶
- Variables
- func IsNil(v any) bool
- func NewBool(b bool) *bool
- func ToDuration(v any) time.Duration
- func ToDurationE(v any) (time.Duration, error)
- func ToString(v any) string
- func ToStringE(v any) (string, error)
- func ToStringSlicePreserveString(v any) []string
- func ToStringSlicePreserveStringE(v any) ([]string, error)
- func TypeToString(v any) (string, bool)
- func Unwrapv(v any) any
- type CloseAdder
- type Closer
- type CloserFunc
- type Closers
- type DevMarker
- type EvictingQueue
- func NewEvictingQueue[T comparable](size int) *EvictingQueue[T]
- func (q *EvictingQueue[T]) Add(v T) *EvictingQueue[T]
- func (q *EvictingQueue[T]) Contains(v T) bool
- func (q *EvictingQueue[T]) Len() int
- func (q *EvictingQueue[T]) Peek() T
- func (q *EvictingQueue[T]) PeekAll() []T
- func (q *EvictingQueue[T]) PeekAllSet() map[T]bool
- type KeyValue
- type KeyValueStr
- type KeyValues
- func NewKeyValuesStrings(key string, values ...string) KeyValues
- func (k KeyValues) KeyString() string
- func (k KeyValues) String() string
- type LowHigh
- type PrintableValueProvider
- type RLocker
- type Unwrapper
- type Zeroer
Variables ¶
This is only used for debugging purposes.
Functions ¶
func IsNil ¶
IsNil reports whether v is nil.
func NewBool ¶
NewTrue returns a pointer to b.
func ToDuration ¶
ToDuration converts v to time.Duration. See ToDurationE if you need to handle errors.
func ToDurationE ¶
ToDurationE converts v to time.Duration.
func ToString ¶
ToString converts v to a string.
func ToStringE ¶
ToStringE converts v to a string.
func ToStringSlicePreserveString ¶
ToStringSlicePreserveString is the same as ToStringSlicePreserveStringE, but it never fails.
func ToStringSlicePreserveStringE ¶
ToStringSlicePreserveStringE converts v to a string slice. If v is a string, it will be wrapped in a string slice.
func TypeToString ¶
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 ¶
Unwrap returns the underlying value of v if it implements Unwrapper, otherwise v is returned.
Types ¶
type CloseAdder ¶
type CloseAdder interface { Add(Closer) }
type Closer ¶
type Closer interface { Close() error }
type CloserFunc ¶
type CloserFunc func() error
CloserFunc is a convenience type to create a Closer from a function.
func (CloserFunc) Close ¶
func (f CloserFunc) Close() error
type Closers ¶
type Closers struct {
// contains filtered or unexported fields
}
func (*Closers) Add ¶
func (*Closers) Close ¶
type DevMarker ¶
type DevMarker interface {
DevOnly()
}
DevMarker is a marker interface for types that should only be used during development.
type EvictingQueue ¶
type EvictingQueue[T comparable] struct { // contains filtered or unexported fields }
EvictingQueue 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.
func NewEvictingQueue ¶
func NewEvictingQueue[T comparable](size int) *EvictingQueue[T]
NewEvictingQueue creates a new queue with the given size.
func (*EvictingQueue[T]) Add ¶
func (q *EvictingQueue[T]) Add(v T) *EvictingQueue[T]
Add adds a new string to the tail of the queue if it's not already there.
func (*EvictingQueue[T]) Contains ¶
func (q *EvictingQueue[T]) Contains(v T) bool
Contains returns whether the queue contains v.
func (*EvictingQueue[T]) Len ¶
func (q *EvictingQueue[T]) Len() int
func (*EvictingQueue[T]) Peek ¶
func (q *EvictingQueue[T]) Peek() T
Peek looks at the last element added to the queue.
func (*EvictingQueue[T]) PeekAll ¶
func (q *EvictingQueue[T]) PeekAll() []T
PeekAll looks at all the elements in the queue, with the newest first.
func (*EvictingQueue[T]) PeekAllSet ¶
func (q *EvictingQueue[T]) PeekAllSet() map[T]bool
PeekAllSet returns PeekAll as a set.
type KeyValue ¶
KeyValue is a interface{} tuple.
type KeyValueStr ¶
KeyValueStr is a string tuple.
type KeyValues ¶
KeyValues holds an key and a slice of values.
func NewKeyValuesStrings ¶
NewKeyValuesStrings takes a given key and slice of values and returns a new KeyValues struct.
func (KeyValues) KeyString ¶
KeyString returns the key as a string, an empty string if conversion fails.
func (KeyValues) String ¶
type LowHigh ¶
LowHigh represents a byte or slice boundary.
func (LowHigh[S]) IsZero ¶
func (LowHigh[S]) Value ¶
func (l LowHigh[S]) Value(source S) S
type PrintableValueProvider ¶
type PrintableValueProvider interface { PrintableValue() any }
PrintableValueProvider is implemented by types that can provide a printable value.
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).
Source Files ¶
closer.go convert.go evictingqueue.go types.go
Directories ¶
Path | Synopsis |
---|---|
common/types/css | |
common/types/hstring |
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 13 hours ago –
Tools for package owners.