gofmts

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

formatter reformats strings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIndentWriter

func NewIndentWriter(w io.Writer, indentColumn, tabWidth int) indentWriter

Types

type FailedDirective

type FailedDirective struct {
	// contains filtered or unexported fields
}

func (FailedDirective) Details

func (i FailedDirective) Details() string

func (FailedDirective) Pos added in v0.2.0

func (i FailedDirective) Pos() token.Pos

func (FailedDirective) Position

func (i FailedDirective) Position() token.Position

func (FailedDirective) String

func (i FailedDirective) String() string

type FormatIssue

type FormatIssue struct {
	// contains filtered or unexported fields
}

func (FormatIssue) Details

func (i FormatIssue) Details() string

func (FormatIssue) Length

func (i FormatIssue) Length() int

func (FormatIssue) Pos added in v0.2.0

func (i FormatIssue) Pos() token.Pos

func (FormatIssue) Position

func (i FormatIssue) Position() token.Position

func (FormatIssue) Replacement

func (i FormatIssue) Replacement() string

func (FormatIssue) String

func (i FormatIssue) String() string

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

func NewFormatter

func NewFormatter() *Formatter

func (*Formatter) Run

func (f *Formatter) Run(src []byte, fset *token.FileSet, file *ast.File) ([]Issue, error)

Run calculates the issues. "src" is the representation of the source, which is used to determine the next tab stop for indentation

type Issue

type Issue interface {
	Details() string
	Position() token.Position
	Pos() token.Pos
	String() string
}

func ApplyReplacements

func ApplyReplacements(w io.Writer, r io.Reader, issues []Issue) (unresolvedIssues []Issue, _ error)

func FormatFile

func FormatFile(src []byte, fset *token.FileSet, file *ast.File) ([]Issue, error)

func SortFile

func SortFile(fset *token.FileSet, file *ast.File) ([]Issue, error)

type IssueWithReplacement

type IssueWithReplacement interface {
	Issue
	Replacement() string
	Length() int
}

type SortIssue

type SortIssue struct {
	// contains filtered or unexported fields
}

func (SortIssue) Details

func (i SortIssue) Details() string

func (SortIssue) Length

func (i SortIssue) Length() int

func (SortIssue) Pos added in v0.2.0

func (i SortIssue) Pos() token.Pos

func (SortIssue) Position

func (i SortIssue) Position() token.Position

func (SortIssue) Replacement

func (i SortIssue) Replacement() string

func (SortIssue) String

func (i SortIssue) String() string

type Sorter

type Sorter struct {
	// contains filtered or unexported fields
}

func NewSorter

func NewSorter() *Sorter

func (*Sorter) Run

func (s *Sorter) Run(fset *token.FileSet, files ...*ast.File) (issues []Issue, _ error)

type UnknownDirective

type UnknownDirective struct {
	// contains filtered or unexported fields
}

func (UnknownDirective) Details

func (i UnknownDirective) Details() string

func (UnknownDirective) Pos added in v0.2.0

func (i UnknownDirective) Pos() token.Pos

func (UnknownDirective) Position

func (i UnknownDirective) Position() token.Position

func (UnknownDirective) String

func (i UnknownDirective) String() string

type UnusedDirective

type UnusedDirective struct {
	// contains filtered or unexported fields
}

func (UnusedDirective) Details

func (i UnusedDirective) Details() string

func (UnusedDirective) Pos added in v0.2.0

func (i UnusedDirective) Pos() token.Pos

func (UnusedDirective) Position

func (i UnusedDirective) Position() token.Position

func (UnusedDirective) String

func (i UnusedDirective) String() string

Jump to

Keyboard shortcuts

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