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

diag

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0, Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package diag holds source positions and diagnostics for the writ policy language. It is deliberately tiny and dependency-free: every other writ package reports through it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasErrors

func HasErrors(ds []Diagnostic) bool

HasErrors reports whether any diagnostic in ds is error-severity.

Types

type Diagnostic

type Diagnostic struct {
	Pos      Pos
	Severity Severity
	Msg      string
}

Diagnostic is one reported problem, anchored to a source position.

func Errorf

func Errorf(pos Pos, format string, args ...any) Diagnostic

Errorf builds an error-severity diagnostic.

func Errors

func Errors(ds []Diagnostic) []Diagnostic

Errors returns only the error-severity diagnostics.

func Warnf

func Warnf(pos Pos, format string, args ...any) Diagnostic

Warnf builds a warning-severity diagnostic.

func Warnings

func Warnings(ds []Diagnostic) []Diagnostic

Warnings returns only the warning-severity diagnostics.

func (Diagnostic) String

func (d Diagnostic) String() string

type Pos

type Pos struct {
	Line int
	Col  int
}

Pos is a 1-based line/column source position.

func (Pos) String

func (p Pos) String() string

type Severity

type Severity int

Severity distinguishes errors (block compilation) from warnings (reported, never blocking).

const (
	Error Severity = iota
	Warning
)

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