Help us shape the future of Go! Take the 2026 Go Developer Survey

diagnostic

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package diagnostic defines the shared compiler diagnostic format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DynamicRule

func DynamicRule(id string) bool

Types

type Diagnostic

type Diagnostic struct {
	Rule      string     `json:"rule"`
	Severity  Severity   `json:"severity"`
	Location  Location   `json:"location"`
	Element   string     `json:"element,omitempty"`
	Path      string     `json:"path,omitempty"`
	Message   string     `json:"message"`
	Hint      string     `json:"hint"`
	Related   []Location `json:"related,omitempty"`
	Reference string     `json:"reference,omitempty"`
}

func Apply

func Apply(issues []Diagnostic, overrides map[string]Severity) []Diagnostic

Apply makes lifecycle notices obey the same policy as normal quality rules. Required execution failures are never passed here as optional notices.

func HardOnly

func HardOnly(issues []Diagnostic) []Diagnostic

func (Diagnostic) String

func (d Diagnostic) String() string

type Location

type Location struct {
	File   string `json:"file"`
	Line   int    `json:"line"`
	Column int    `json:"column"`
	Offset int    `json:"offset"`
}

func At

func At(file string, raw []byte, offset int) Location

type RuleInfo

type RuleInfo struct {
	ID       string `json:"id"`
	Summary  string `json:"summary"`
	Help     string `json:"help"`
	Required bool   `json:"required,omitempty"`
	Project  string `json:"project,omitempty"` // Needs the lfm project's sources.
}

RuleInfo is the single definition of a rule's identity and help. Summary is one line naming what is checked; Help explains what triggers it, why it matters and how to resolve it. Required rules can never leave error level.

func OperationalRules

func OperationalRules() []RuleInfo

OperationalRules are emitted outside individual HTML/template checks. Lighthouse owns a versioned audit namespace, so its concrete IDs are dynamic.

type Severity

type Severity string
const (
	Error   Severity = "error"
	Warning Severity = "warn"
	Off     Severity = "off"
)

func Level

func Level(id string, overrides map[string]Severity) Severity

type Source

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

Source indexes line starts once for repeated source-position lookups. Columns/offsets use UTF-8 bytes, matching Go's template and JSON parsers.

func NewSource

func NewSource(file string, raw []byte) Source

func (Source) At

func (s Source) At(offset int) Location

type Summary

type Summary struct {
	Diagnostics []Diagnostic `json:"diagnostics"`
	Errors      int          `json:"errors"`
	Warnings    int          `json:"warnings"`
}

func Summarize

func Summarize(issues []Diagnostic) Summary

Jump to

Keyboard shortcuts

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