utils

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapComparePresentOnly added in v0.6.0

func MapComparePresentOnly[K comparable, V comparable](a, b map[K]V) []K

MapComparePresentOnly compares 2 maps but only the keys that are present in both maps. Returns a slice of keys that are different

func MapDiff added in v0.3.0

func MapDiff[K comparable, V comparable](a, b map[K]V) map[K][]V

MapDiff returns diff as slices a_value,b_value. Missing values are represented as Zero values

func Move

func Move[T any](a []T, e, t int) []T

Move moves the element at position e to the position t returns new slice

func ResolveDependencies added in v0.3.0

func ResolveDependencies[D Dependency[T], T comparable](us []D) ([]D, error)

ResolveDependencies takes a slice of Elements that implement Dependency and returns a sorted slice. All Elements that provide a feature (Dependency.Provides()) are sorted before Elements which depends(Dependency.Depends()) on them If there is a dependency loop an error is return together the slice of the resolved Dependencies

Types

type Dependency added in v0.3.0

type Dependency[T comparable] interface {
	Provides() T
	Depends() []T
}

type LineNumberTracker added in v0.4.0

type LineNumberTracker []trackedLine

func (*LineNumberTracker) LineAtOffset added in v0.4.0

func (l *LineNumberTracker) LineAtOffset(offset int64) (int, int64)

LineAtOffset returns at which line/pos an offset byte was in the stream written to the LineNumberTracker. Returns -1 if offset was not read yet

func (*LineNumberTracker) Write added in v0.4.0

func (l *LineNumberTracker) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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