pkg

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPattern      = fmt.Errorf("invalid pattern")
	ErrInvalidSplatPattern = fmt.Errorf("splat patterns must end with *")
	ErrItemAlreadyExist    = fmt.Errorf("item already exist")
)

Functions

func PathClean

func PathClean(p string) string

PathClean is the URL version of path.Clean, it returns a canonical URL path for p, eliminating . and .. elements.

The following rules are applied iteratively until no further processing can be done:

  1. Replace multiple slashes with a single slash.
  2. Eliminate each . path name element (the current directory).
  3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
  4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.

If the result of this process is an empty string, "/" is returned

Types

type WildcardStore

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

WildcardStore utility to persist and search items using wildcards. Used for channels, topics and events

IMPORTANT: It is not safe for insertion in a concurrent scenario. Items should only persist during system startup.

func (*WildcardStore[T]) Insert

func (s *WildcardStore[T]) Insert(keyPattern string, value T) error

func (*WildcardStore[T]) Match

func (s *WildcardStore[T]) Match(key string) (out T)

Match returns the value corresponding to the first occurrence of the keyPattern that matches the given key

func (*WildcardStore[T]) MatchAll

func (s *WildcardStore[T]) MatchAll(key string) []T

MatchAll returns all existing values that match the given key

Jump to

Keyboard shortcuts

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