util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package util provides a generic type representing a mathematical set, and convenience functions for generating error values for packages github.com/jub0bs/fcors and github.com/jub0bs/fcors/risky.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, a ...any) error

Errorf works the same way as fmt.Errorf does, but prefixes the resulting error message with "fcors: ".

func InvalidOriginPatternErr

func InvalidOriginPatternErr(s string) error

InvalidOriginPatternErr returns an error about invalid origin pattern s.

func NewError

func NewError(text string) error

NewError works the same way as errors.New does, but prefixes the resulting error message with "fcors: ".

func NewErrorRisky

func NewErrorRisky(text string) error

NewErrorRisky works the same way as errors.New does, but prefixes the resulting error message with "fcors/risky: ".

func SortCombine

func SortCombine(s Set[string], delim string) string

SortCombine sorts the elements of s in lexicographical order, joins them with delim, and returns the resulting string.

Types

type Set

type Set[E comparable] map[E]struct{}

A Set represents a mathematical set whose elements have type E. Don't expect this type to work properly for elements that are not reflexive for equality.

func NewSet

func NewSet[E comparable](first E, rest ...E) Set[E]

NewSet returns a Set that contains all of es (and no other elements).

func (Set[E]) Add

func (s Set[E]) Add(e E)

Add adds e to s.

func (Set[E]) Contains

func (s Set[E]) Contains(e E) bool

Contains returns true if e is an element of s, and false otherwise.

Jump to

Keyboard shortcuts

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