Documentation
¶
Overview ¶
Package formatters groups the formatting tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONInputError ¶ added in v0.2.0
JSONInputError turns an encoding/json error on in into an InputError with the line and column of the culprit. Other JSON tools reuse it.
func ValidateXML ¶ added in v1.0.0
ValidateXML checks that in is well-formed XML with at least one element. Errors are InputErrors with the line and, as far as encoding/xml tells, the column where the decoder stopped. Other XML tools reuse it.
Types ¶
type JSONFormat ¶
type JSONFormat struct{}
JSONFormat indents, minifies and sorts JSON.
func (JSONFormat) Detect ¶
func (JSONFormat) Detect(sample string) float64
Detect recognises a valid JSON object or array.
func (JSONFormat) Spec ¶
func (JSONFormat) Spec() tool.Spec
type SQLFormat ¶ added in v1.0.0
type SQLFormat struct{}
SQLFormat formats SQL with its own tokenizer, without a dialect: each clause starts a line and its body is indented below; subqueries, CTEs and column lists open an indented block. Strings, quoted identifiers and comments are kept as written.
func (SQLFormat) Detect ¶ added in v1.0.0
Detect recognises text that starts with a common SQL statement.
type XMLFormat ¶
type XMLFormat struct{}
XMLFormat re-indents XML keeping each token's original text (attributes, comments, CDATA, processing instructions and DOCTYPE).
func (XMLFormat) Detect ¶
Detect recognises XML that tokenises without errors in its first 50 tokens and has at least one element.