issue

package
v0.0.0-...-1b8cbf5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package issue provides a common set of tools for describing problems encountered during processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

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

Definition is a definition of a particular type of issue.

func NewError

func NewError(id, description string) *Definition

NewError returns a new Definition for an Error issue.

func NewInfo

func NewInfo(id, description string) *Definition

NewInfo returns a new Definition for an Info issue.

func NewInternal

func NewInternal(id, description string) *Definition

NewInternal returns a new Definition for an Internal issue.

func NewWarning

func NewWarning(id, description string) *Definition

NewWarning returns a new Definition for a Warning issue.

func (Definition) Description

func (d Definition) Description() string

Description returns the standard human-readable description of the issue.

func (Definition) ID

func (d Definition) ID() string

ID returns the unqiue identifier of this type of issue.

func (Definition) Severity

func (d Definition) Severity() Severity

Severity returns the severity of the issue.

func (Definition) String

func (d Definition) String() string

type Issue

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

Issue describes an issue found while processing input.

Issues never represent internal errors encountered in processing, those are conveyed via normal [error] returns.

func New

func New(def *Definition, file *source.File, loc source.Location) *Issue

New returns a new issue at a specific location with a formatted message.

func (*Issue) AppendRelated

func (i *Issue) AppendRelated(file *source.File, loc source.Location, msg string, args ...any) *Issue

AppendRelated adds a related source location to this issue.

func (*Issue) Definition

func (i *Issue) Definition() *Definition

Definition returns the metadata that defines what kind of issue this is.

func (*Issue) Detail

func (i *Issue) Detail() string

Detail returns supplemental information that is required to clarify the issue if any.

func (*Issue) File

func (i *Issue) File() *source.File

File returns the source file where the issue was found.

func (*Issue) Location

func (i *Issue) Location() source.Location

Location returns the source location where the issue was found.

func (*Issue) Related

func (i *Issue) Related() iter.Seq2[int, Related]

Related returns an iterator over all related locations.

func (*Issue) String

func (i *Issue) String() string

func (*Issue) WithDetail

func (i *Issue) WithDetail(msg string, args ...any) *Issue

WithDetail adds formatted detail information to this issue and returns it.

type Log

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

Log is an ordered record of issues collected during processing.

func NewLog

func NewLog() *Log

NewLog returns an empty log.

func (*Log) All

func (l *Log) All() iter.Seq2[int, *Issue]

All returns an iterator over all issues in the log.

func (*Log) Append

func (l *Log) Append(issue *Issue)

Append appends an issue to the log.

func (*Log) Errors

func (l *Log) Errors() iter.Seq[*Issue]

Errors returns an iterator over all Error issues in the log.

func (*Log) First

func (l *Log) First() *Issue

First returns the first issue in the log or nil if the log is empty.

func (*Log) HasError

func (l *Log) HasError() bool

HasError returns true if the log has at least one Error issue.

func (*Log) HasInfo

func (l *Log) HasInfo() bool

HasInfo returns true if the log has at least one Info issue.

func (*Log) HasInternal

func (l *Log) HasInternal() bool

HasInternal returns true if the log has at least one Internal issue.

func (*Log) HasWarning

func (l *Log) HasWarning() bool

HasWarning returns true if the log has at least one Warning issue.

func (*Log) Infos

func (l *Log) Infos() iter.Seq[*Issue]

Infos returns an iterator over all Info issues in the log.

func (*Log) Last

func (l *Log) Last() *Issue

Last returns the last issue in the log (i.e. the most recently appended) or nil if the log is empty.

func (*Log) Len

func (l *Log) Len() int

Len returns the total number of issues in the log.

func (*Log) String

func (l *Log) String() string

func (*Log) Warnings

func (l *Log) Warnings() iter.Seq[*Issue]

Warnings returns an iterator over all Warning issues in the log.

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

Related is a separate piece of source code that relates to some issue.

func (Related) Detail

func (r Related) Detail() string

Detail returns supplemental information that is required to clarify how this location relates to the overall issue.

func (Related) File

func (r Related) File() *source.File

File returns the source file where the related piece of information is found.

func (Related) Location

func (r Related) Location() source.Location

Location returns the source location of a related piece of information.

func (Related) String

func (r Related) String() string

type Severity

type Severity uint8

Severity describes how serious an issue detected by a processing step is.

const (
	// Internal indicates an issue due to a fault in the system rather than user
	// input. The user is not expected to fix these issue, rather report them to
	// the system owner.
	//
	// Internal issues almost always interrupt processing.
	Internal Severity = iota
	// Error indicates an issue that the user must address. This likely indicates
	// that the input is invalid in some fundamental way (e.g. bad syntax).
	//
	// Error issues from one processing phase usually prevent progression onto the
	// next phase.
	Error
	// Warning indicates an issue that the user should address. While technically
	// valid, the input may not function as the user intended (e.g. unused
	// variables).
	//
	// Warning issues should never prevent further processing.
	Warning
	// Info indicates an issue that the user may address. This may be suggestions
	// to improve style, efficiency, etc.
	//
	// Info issues should never prevent further processing.
	Info
)

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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