utils

package
v0.0.0-...-8d54791 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data any, response any) error

Decode is a wrapper around mapstructure.Decode

func DecodeMap

func DecodeMap[V any](data map[string]any, response map[int]V) error

DecodeMap is a wrapper around mapstructure.WeakDecode for multiple values passed as a map[string]any

func DecodeSlice

func DecodeSlice[V any](data []any, response []V) ([]V, error)

DecodeSlice is a wrapper around mapstructure.WeakDecode for multiple values passed as a []any - response must be a pointer to a slices

func NewBool

func NewBool(b bool) *bool

NewBool creates a new bool pointer from a bool value.

func NewFloat64

func NewFloat64(f float64) *float64

NewFloat64 creates a new float64 pointer from a float64 value.

func NewInt

func NewInt(i int) *int

NewInt creates a new int pointer from an int value.

func NewString

func NewString(s string) *string

NewString creates a new string pointer from a string value.

Types

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue is a generic queue implementation based on slices.

func NewQueue

func NewQueue[T any]() *Queue[T]

NewQueue creates a new queue.

func NewQueueFromSlice

func NewQueueFromSlice[T any](slice []T) *Queue[T]

NewQueueFromSlice creates a new queue from a slice.

func (*Queue[T]) Clear

func (q *Queue[T]) Clear()

Clear removes all items from the queue.

func (*Queue[T]) Empty

func (q *Queue[T]) Empty() bool

Empty returns true if the queue is empty.

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

Len returns the length of the queue.

func (*Queue[T]) Peek

func (q *Queue[T]) Peek() *T

Peek returns the first item in the queue without removing it.

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() *T

Pop removes an item from the queue.

func (*Queue[T]) Push

func (q *Queue[T]) Push(item *T)

Push adds an item to the queue.

func (*Queue[T]) Slice

func (q *Queue[T]) Slice() []T

Slice returns copy of queue data as slice.

func (*Queue[T]) Trim

func (q *Queue[T]) Trim(n int)

Trim removes all items from the queue except the last n items.

Jump to

Keyboard shortcuts

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