util

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package util provides miscellaneous utility functions used across the argo-go library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPathIndex

func AddPathIndex(p ast.Path, i int) ast.Path

AddPathIndex appends an integer index to an ast.Path.

func AddPathName

func AddPathName(p ast.Path, s string) ast.Path

AddPathName appends a string name to an ast.Path.

func FormatPath

func FormatPath(p ast.Path) string

func GroupBy

func GroupBy[T any, K comparable](array []T, extract func(T) K) map[K][]T

GroupBy groups elements of a slice into a map based on a key extracted from each element.

Types

type OrderedMapJSON

type OrderedMapJSON[K comparable, V any] struct {
	*orderedmap.OrderedMap[K, V]
}

OrderedMapJSON is a wrapper around orderedmap.OrderedMap to allow custom JSON marshalling. It needs to be generic to match the orderedmap.OrderedMap it wraps.

func NewOrderedMapJSON

func NewOrderedMapJSON[K comparable, V any](om *orderedmap.OrderedMap[K, V]) *OrderedMapJSON[K, V]

NewOrderedMapJSON creates a new OrderedMapJSON wrapper.

func (OrderedMapJSON[K, V]) MarshalJSON

func (omj OrderedMapJSON[K, V]) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. This method will be called by json.Marshal and json.MarshalIndent.

func (OrderedMapJSON[K, V]) MustMarshalJSON

func (omj OrderedMapJSON[K, V]) MustMarshalJSON() []byte

MustMarshalJSON calls MarshalJSON and panics if an error occurs.

Jump to

Keyboard shortcuts

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