wyr

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

Documentation

Overview

Package wyr serves Would You Rather polls from the embedded WYR dataset. Each poll has two options with historical vote counts from the source — useful for showing "what other people picked" stats next to the choice. Call Load once at startup with the embed.FS from the parent package, then call Random 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 polls. 0 means Load wasn't called or the dataset was empty.

func Load

func Load(fsys fs.FS) error

Load reads datasets/WYR.csv from fsys into memory. Call once at startup. After Load returns nil, Random and Count are safe for concurrent use.

Types

type Poll

type Poll struct {
	OptionA string
	VotesA  int
	OptionB string
	VotesB  int
}

Poll is a single Would You Rather entry.

func Random

func Random() Poll

Random returns a uniformly random Poll. Returns the zero-value Poll (empty options) when Load has not been called or the dataset is empty, so callers can guard on OptionA == "".

Jump to

Keyboard shortcuts

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