text

package
v0.0.0-...-f5ffb6e Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultFailureFields are the default FailureFields.
	DefaultFailureFields = []FailureField{
		FailureFieldFilename,
		FailureFieldLine,
		FailureFieldColumn,
		FailureFieldMessage,
	}
)

Functions

func SortFailures

func SortFailures(failures []*Failure)

SortFailures sorts the Failures, by filename, line, column, id, message.

Types

type Failure

type Failure struct {
	Filename string `json:"filename,omitempty"`
	Line     int    `json:"line,omitempty"`
	Column   int    `json:"column,omitempty"`
	LintID   string `json:"lint_id,omitempty"`
	Message  string `json:"message,omitempty"`
}

Failure is a failure with a position in text.

func NewFailuref

func NewFailuref(position scanner.Position, lintID string, format string, args ...interface{}) *Failure

NewFailuref is a helper that returns a new Failure.

func (*Failure) Fprintln

func (f *Failure) Fprintln(writer FailureWriter, fields ...FailureField) error

Fprintln prints the Failure to the writer with the given ordered fields.

func (*Failure) String

func (f *Failure) String() string

String implements fmt.Stringer.

type FailureField

type FailureField int

FailureField references a field of a Failure.

const (
	// FailureFieldFilename references the Filename field of a Failure.
	FailureFieldFilename FailureField = iota
	// FailureFieldLine references the Line field of a Failure.
	FailureFieldLine
	// FailureFieldColumn references the Column field of a Failure.
	FailureFieldColumn
	// FailureFieldID references the ID field of a Failure.
	FailureFieldID
	// FailureFieldMessage references the Message field of a Failure.
	FailureFieldMessage
)

func ParseColonSeparatedFailureFields

func ParseColonSeparatedFailureFields(s string) ([]FailureField, error)

ParseColonSeparatedFailureFields parses FailureFields from the given string. FailureFields are expected to be colon-separated in the given string. Input is case-insensitive. If the string is empty, DefaultFailureFields will be returned.

func ParseFailureField

func ParseFailureField(s string) (FailureField, error)

ParseFailureField parses the FailureField from the given string.

Input is case-insensitive.

func (FailureField) String

func (f FailureField) String() string

String implements fmt.Stringer.

type FailureWriter

type FailureWriter interface {
	WriteRune(rune) (int, error)
	WriteString(string) (int, error)
}

FailureWriter is a writer that Failure.Println can accept.

Both bytes.Buffer and bufio.Writer implement this.

Jump to

Keyboard shortcuts

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