Documentation
¶
Overview ¶
Package header reads the declaration header of an authored SQL file: the "--|" declarations that precede the body the engine receives. The header is the loader's, never sent. The package knows no keys; each consumer decides which keys it accepts and what their values mean. query reads tier, native, transaction, key, and field; migrate reads transaction; sqlint reads what each role's checks need.
The package exports:
- Marker, the prefix that opens a declaration line
- Parse, which reads a file's header
- Header, one file's declarations and where its body begins
- Declaration, one declaration and the line that opens it
Index ¶
Constants ¶
const Marker = "--|"
Marker opens a declaration line. It is a comment to every engine that reads "--" without requiring whitespace after it, and it is never sent: the header is the loader's, and a consumer hands the engine the body.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Declaration ¶
Declaration is one "--| key: value" declaration of the header, with the 1-based number of the line that opens it for a consumer's error messages. A value folded across several lines is joined into one Value.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header is the declarations of one file, in file order, and where the body begins. A key may repeat; "field" does, once per column.
func Parse ¶
Parse reads the header from text: the leading run of lines that are blank, plain "--" comments (prose, skipped), or "--|" declarations. The header ends at the first line that is none of those. A declaration line that is not "--| key: value", or a declaration after the body has begun, is an error.
A long value folds across lines: "--| [key]: more" repeats the key of the declaration it continues in brackets, and Parse appends its text to that declaration's value with a single space between the pieces. A fold continues the declaration on the line immediately above it, so a blank line, a prose line, or another declaration ends the run a fold may join. A fold whose key is not the one it continues, or that continues nothing, is an error.
func (Header) Declarations ¶
func (h Header) Declarations() []Declaration
Declarations returns every declaration in file order.
func (Header) End ¶
End returns the byte offset at which the body begins: the start of the first line that is neither a comment nor blank, or the length of the text when there is no body. A consumer sends text[End():] to the engine and scans it for what only the body may contain.