utils

package
v0.5.42 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsDigits

func ContainsDigits(s string) bool

func CopyStringFile

func CopyStringFile(src string, dest string) (string, error)

CopyStringFile

func EnsureDir added in v0.5.39

func EnsureDir(dir string) error

func HSVToRGB

func HSVToRGB(h, s, v float64) (int32, int32, int32)

func IntersectionSlices

func IntersectionSlices[T constraints.Ordered](a, b []T) []T

func MakeURLStringSlug added in v0.5.39

func MakeURLStringSlug(u string) string

func MostOcc

func MostOcc[T comparable](predictions []T) T

func MustEnsureDir added in v0.5.39

func MustEnsureDir(dir string)

func OnlyContainsDigits

func OnlyContainsDigits(s string) bool

func ReadBytesFile added in v0.5.39

func ReadBytesFile(path string) ([]byte, error)

ReadBytesFile returns the data at the given path declared in a "data" attribute of a BUILD.bazel rule.

func ReadStringFile

func ReadStringFile(path string) (string, error)

ReadStringFile returns a string with the data at the given path declared in a "data" attribute of a BUILD.bazel rule.

func ReverseSlice

func ReverseSlice[T any](s []T)

func RuneIsOneOf

func RuneIsOneOf(r rune, rs []rune) bool

func ShortenString

func ShortenString(s string, l int) string

func SliceEquals

func SliceEquals[T constraints.Ordered](a, b []T) bool

func SortSlice

func SortSlice[T constraints.Ordered](s []T)

func TrimURLScheme added in v0.5.39

func TrimURLScheme(u string) string

func WriteBytesFile

func WriteBytesFile(path string, content []byte) error

WriteBytesFile writes the given file contents to the given path.

func WriteJSONBytes added in v0.5.39

func WriteJSONBytes(data any) ([]byte, error)

WriteJSONString writes the given JSON to a string.

func WriteJSONFile

func WriteJSONFile(path string, data any) error

WriteJSONFile writes the given file contents to the given path.

func WriteStringFile

func WriteStringFile(path string, content string) error

WriteStringFile writes the given file contents to the given path.

func WriteTempStringFile

func WriteTempStringFile(path string, content string) (string, error)

WriteTempStringFile writes the given file contents to the given path with a random id before the file type suffix (separared by a ".") if one is present, or appended at the end otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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