numbers

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 5 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package numbers reads a numbers file. It lists every number a project uses that is not true by definition. Each number has a name, says what it is and says where it came from.

Any measured number names its source. That is the source's key in the project's sources.yaml, the place in it and the text read there. A picked number says who picked it and when.

The rules, 10-18: a measured number is pulled from its source and never typed from memory. Any picked number is config, in yml. The code names them and asks for them here. It holds none of its own.

The file is read whole by package yamlfile, which refuses a key nobody knows, a key written twice and a value of the wrong type, each at its line. Read then refuses a number missing what its kind needs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind string

Kind is where a number came from: measured, or picked.

const (
	// Measured is a number read from a published source.
	Measured Kind = "measured"
	// Picked is a number someone chose, and said why.
	Picked Kind = "picked"
)

type Number

type Number struct {
	// Name is what the code asks for the number by.
	Name string `yaml:"name"`
	// Value is the number.
	Value float64 `yaml:"value"`
	// Unit is the number's unit, as written; none for a pure number.
	Unit string `yaml:"unit"`
	// Says is what the number is.
	Says string `yaml:"says"`
	// Kind is where the number came from.
	Kind Kind `yaml:"kind"`
	// From is the source a measured number was read from. A picked
	// number has none.
	From *Source `yaml:"source"`
	// By is who picked a picked number, and when. A measured number has
	// none.
	By string `yaml:"by"`
}

Number is one named number. It has a value and a unit and a line on what it is, and a kind. Each measured one has its source. Each picked one says who picked it.

type Numbers

type Numbers []Number

Numbers is a numbers file read: every number, in the order written.

func Read

func Read(file string, raw []byte) (Numbers, error)

Read is the numbers a file holds, or nil and why not. It refuses what package yamlfile refuses: a file that is not YAML, a key nobody knows, a key written twice, a value of the wrong type.

It refuses an entry missing what its kind needs, a name written twice and a name that reads as a number.

A name that parses as a number in any base is refused: 010 and 0x10 are numbers, and nobody should ask for Get("010"). The message ends "call the number something else". A name such as yes or true is a word and is taken as written.

Every refusal is reported together, with the file named once. A refusal by yamlfile is reported alone, as it stops the file being read.

func (Numbers) Get

func (read Numbers) Get(name string) (*Number, error)

Get is the number of a name, as a pointer to its place in the list, or nil and a refusal naming the number it does not hold.

type Source

type Source struct {
	// Key is the source's key in the project's sources.yaml.
	Key string `yaml:"key"`
	// Where is the place in the source: page, table, row and column.
	Where string `yaml:"where"`
	// Page is the page of a paged source the text is on, counted as the
	// file counts them; none for a source that is not paged.
	Page int `yaml:"page"`
	// Text is what the source reads there, as a check would find it.
	Text string `yaml:"text"`
	// Excerpt optionally scopes numeric text to a surrounding quotation.
	// This distinguishes a short value from unrelated page numbers.
	Excerpt string `yaml:"excerpt,omitempty"`
}

Source is where a measured number was read. It holds the source's key in sources.yaml, the place in it, the page of a paged source and the text found there.

Jump to

Keyboard shortcuts

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