buddie

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: 4 Imported by: 0

Documentation

Overview

Package buddie serves a random image of the dog BuddieBot was named after, embedded in the binary alongside the text datasets. Call Load once at startup with the embed.FS from the parent package, then call Random freely from anywhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count() int

Count returns the number of loaded images. 0 means Load wasn't called or the dataset directory was empty.

func Load

func Load(fsys fs.FS) error

Load reads every file under datasets/buddie/ into memory. Call once at startup. After Load returns nil, Random is safe for concurrent use. Eager-loads to match the rest of bb_data's "load once, lock-free reads" pattern; the embedded folder is small (~2 MiB), so the memory cost is trivial vs the per-call simplicity it buys.

Types

type Image

type Image struct {
	Filename string
	Data     []byte
}

Image is one picked entry: the file's basename + raw bytes. Files in datasets/buddie are JPEG today, but the loader doesn't care about the extension — anything in the directory is offered as-is.

func Random

func Random() Image

Random returns a uniformly random Image. Returns the zero Image (empty Filename, nil Data) when Load has not been called or the dataset is empty — callers can guard on Filename == "".

Jump to

Keyboard shortcuts

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