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 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 ¶
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.
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.