Documentation
¶
Overview ¶
Package yaml reads a file of a module, YAML 1.2.2 under its Core schema, into a JSON value, and refuses a file that breaks a rule yaml.*, naming the rule and its place, or that is not YAML 1.2.2 at all (format/README.md, section 4; R45 spec). The check of a module reads each file through it, and the test of vectors reads the vectors of the rules yaml.* (R21).
go.yaml.in/yaml/v4 parses the file into its tree of nodes. It keeps some of YAML 1.1 and lets through some of what YAML 1.2.2 refuses, so passes of this package go around it, each in a file of its own: text.go before the parse, errors.go on its errors, walk.go over its tree for the rules, and layout.go over its tree for what YAML 1.2.2 refuses and v4 reads all the same. Each pass names what of v4 it closes, and a test holds it (R21).
Index ¶
Constants ¶
const ( RuleEncoding = "yaml.encoding" RuleSingleDocument = "yaml.single-document" RuleNoDirectives = "yaml.no-directives" RuleNoAnchors = "yaml.no-anchors" RuleNoTags = "yaml.no-tags" RuleStringKeys = "yaml.string-keys" RuleUniqueKeys = "yaml.unique-keys" RuleJSONScalars = "yaml.json-scalars" RulePlainStrings = "yaml.plain-strings" RuleCharacters = "yaml.characters" )
The rules of section 4 of format/README.md, in its order.
Variables ¶
var Rules = []string{ RuleEncoding, RuleSingleDocument, RuleNoDirectives, RuleNoAnchors, RuleNoTags, RuleStringKeys, RuleUniqueKeys, RuleJSONScalars, RulePlainStrings, RuleCharacters, }
Rules are the IDs of the rules yaml.*, in the order of section 4.
Functions ¶
func Read ¶
Read reads a file of a module into its JSON value: a map[string]any, []any, string, int64 for a number written with neither a fraction nor an exponent, float64 for any other number, bool, or nil. A file that breaks a rule yaml.*, or is not YAML 1.2.2, gives a *Refusal and no value (format/README.md, section 4).
Types ¶
type Breach ¶
type Breach struct {
Rule string
// The place in the file as written: the line and the column, both from 1. The column counts
// characters, a byte order mark among them, and a byte that is no part of a UTF-8 character
// counts as one.
Line, Column int
Message string
}
A Breach is one reason a file is refused: a rule it breaks, or, when Rule is empty, that it is not YAML 1.2.2 at all. The format gives that refusal no ID: a file that is not YAML is no module file, whatever its rules say (format/README.md, section 4).