util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToPascalCase added in v0.2.0

func ToPascalCase(s string) string

ToPascalCase converts a string to PascalCase. It's just a wrapper around strcase.ToCamel with a more meaningful name.

func WrapChan

func WrapChan[T any](errc chan error, fn func() (T, error)) chan T

WrapChan wraps a function returning a value and an error into a channel.

  • The error is sent to its channel only if it's not nil.
  • The value is sent to its channel only if there is no error.

Types

type SortedMap added in v0.2.0

type SortedMap[K cmp.Ordered, V any] struct {
	// contains filtered or unexported fields
}

func NewSortedMap added in v0.2.0

func NewSortedMap[K cmp.Ordered, V any](len int) *SortedMap[K, V]

func (*SortedMap[K, V]) Delete added in v0.2.0

func (m *SortedMap[K, V]) Delete(k K)

func (*SortedMap[K, V]) Get added in v0.2.0

func (m *SortedMap[K, V]) Get(k K) (V, bool)

Get returns the value associated with the key and a boolean indicating if the key was found.

func (*SortedMap[K, V]) GetX added in v0.2.0

func (m *SortedMap[K, V]) GetX(k K) V

GetX returns the value associated with the key. If the key is not found, it returns the zero value of the value type.

func (*SortedMap[K, V]) Keys added in v0.2.0

func (m *SortedMap[K, V]) Keys() []K

func (*SortedMap[K, V]) Len added in v0.2.0

func (m *SortedMap[K, V]) Len() int

func (*SortedMap[K, V]) Set added in v0.2.0

func (m *SortedMap[K, V]) Set(k K, v V)

func (*SortedMap[K, V]) Values added in v0.2.0

func (m *SortedMap[K, V]) Values() []V

Jump to

Keyboard shortcuts

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