pick

package
v0.0.0-...-0c3cbb8 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pick holds tiny helpers shared by every dataset subpackage: uniform random selection plus filesystem readers for JSON, JSONL, and line-delimited text files. Internal by design — not part of the public API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadJSON

func LoadJSON(fsys fs.FS, path string, out any) error

LoadJSON reads path from fsys and decodes the JSON into out.

func LoadJSONL

func LoadJSONL[T any](fsys fs.FS, path string) ([]T, error)

LoadJSONL reads path from fsys as a stream of JSON values and decodes each into a value of type T. Tolerates JSON Lines (one value per line), concatenated values with no separator, and arbitrary whitespace between values — useful because hand-curated JSONL files occasionally have a missing newline between records.

func LoadLines

func LoadLines(fsys fs.FS, path string) ([]string, error)

LoadLines reads path from fsys and returns each non-empty line with trailing \r stripped. Handles both LF and CRLF input.

func Random

func Random[T any](xs []T) T

Random returns a uniformly random element of xs. Returns the zero value of T when xs is empty so callers don't have to special-case the unloaded state.

Types

This section is empty.

Jump to

Keyboard shortcuts

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