util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast added in v0.54.0

func Cast[M ~map[K]V, K comparable, V any](input M) map[K]any

Cast turns a map[K]V to a map[K]any, so values will downcast to 'any' type.

func EncodeBBox added in v1.5.0

func EncodeBBox(bbox geom.T) (*[]float64, error)

EncodeBBox encodes b as a GeoJson Bounding Box. adapted from https://github.com/twpayne/go-geom/blob/b22fd061f1531a51582333b5bd45710a455c4978/encoding/geojson/geojson.go#L525

func Inverse added in v0.54.0

func Inverse(input map[string]string) map[string]string

Inverse switches the values to keys and the keys to values.

func Keys

func Keys[M ~map[K]V, K comparable, V any](input M) []K

Keys returns the keys of the map m. The keys will be an indeterminate order.

func MergeJSON

func MergeJSON(x1, x2 []byte, orderBy func(output map[string]any) any) ([]byte, error)

MergeJSON merges the two JSON byte slices. It returns an error if x1 or x2 cannot be JSON-unmarshalled, or the merged JSON is invalid.

Optionally, an orderBy function can be provided to alter the key order in the resulting JSON.

func PrettyPrintJSON

func PrettyPrintJSON(content []byte, name string) []byte

func ReadFile

func ReadFile(filePath string) string

ReadFile read a plain or gzipped file and return contents as string.

Types

type JSONEncoder added in v1.5.0

type JSONEncoder interface {
	Encode(input any) error
}

func GetJSONEncoder added in v1.5.0

func GetJSONEncoder(w io.Writer) JSONEncoder

GetJSONEncoder Create JSON encoder. Note escaping of '<', '>' and '&' is disabled (HTMLEscape is false). Especially the '&' is important since we use this character in, for example, next/prev links.

Jump to

Keyboard shortcuts

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