Documentation
¶
Overview ¶
Package header reads the declaration header of an authored SQL file: the leading run of blank lines, plain "--" comments (prose, skipped), and "--|" declaration lines of the form "--| key: value", ending at the first line that is none of those. The marker makes a declaration definite: a "--|" line that is not a declaration is an error, and a plain comment is never one. The header is the loader's; End marks where the body the engine receives begins. 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.
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" line of the header, with its 1-based line number for a consumer's error messages.
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.
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.