formatters

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func JSONInputError(in string, err error) error

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

func ValidateXML(in string) error

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) Run

func (j JSONFormat) Run(ctx context.Context, req tool.Request) (tool.Result, error)

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

func (SQLFormat) Detect(sample string) float64

Detect recognises text that starts with a common SQL statement.

func (SQLFormat) Run added in v1.0.0

func (f SQLFormat) Run(ctx context.Context, req tool.Request) (tool.Result, error)

func (SQLFormat) Spec added in v1.0.0

func (SQLFormat) Spec() tool.Spec

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

func (XMLFormat) Detect(sample string) float64

Detect recognises XML that tokenises without errors in its first 50 tokens and has at least one element.

func (XMLFormat) Run

func (x XMLFormat) Run(ctx context.Context, req tool.Request) (tool.Result, error)

func (XMLFormat) Spec

func (XMLFormat) Spec() tool.Spec

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL