hclfmt

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const NumSpacesPerIndent = 1

Variables

This section is empty.

Functions

func Format

func Format(ctx context.Context, cfg format.Configuration, fs afero.Fs, fle string) error

Process uses the hcl2 library to format the hcl file. This will attempt to parse the HCL file first to ensure that there are no syntax errors, before attempting to format it.

func FormatBytes

func FormatBytes(cfg format.Configuration, src []byte) (io.Reader, error)

Types

type Formatter

type Formatter struct {
}

func NewFormatter

func NewFormatter() *Formatter

func (*Formatter) Format

func (me *Formatter) Format(ctx context.Context, cfg format.Configuration, read io.Reader) (io.Reader, error)

func (*Formatter) Targets

func (me *Formatter) Targets() []string

type Token

type Token struct {
	hclwrite.Token
	TabsBefore int
}

type Tokens

type Tokens []*Token

func (Tokens) Columns

func (ts Tokens) Columns() int

Columns returns the number of columns (grapheme clusters) the token sequence occupies. The result is not meaningful if there are newline or single-line comment tokens in the sequence.

func (Tokens) WriteTo

func (ts Tokens) WriteTo(wr io.Writer, cfg format.Configuration) (int64, error)

WriteTo takes an io.Writer and writes the bytes for each token to it, along with the spacing that separates each token. In other words, this allows serializing the tokens to a file or other such byte stream.

Jump to

Keyboard shortcuts

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