doctor

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package doctor is the report a tool's `doctor` command prints: one line per check, ok, warn or fail, as text for people or versioned JSON for agents. A warning is something that still works in a reduced way; only a failure makes Write return ErrProblems.

Index

Constants

View Source
const (
	OK   = "ok"
	Warn = "warn"
	Fail = "fail"
)
View Source
const SchemaVersion = 1

SchemaVersion versions the JSON shape, for agents that parse it.

Variables

View Source
var ErrProblems = errors.New("doctor found problems")

ErrProblems is returned by Write when a check failed.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	Detail string `json:"detail"`
}

Check is one line of the report.

func Binary

func Binary(name string) Check

Binary checks the running executable and whether name on PATH is found; not on PATH is a warning, since agents and hooks call it by name.

type Report

type Report struct {
	SchemaVersion int     `json:"schemaVersion"`
	Version       string  `json:"version"`
	Checks        []Check `json:"checks"`
}

Report collects checks.

func New

func New(version string) *Report

New starts a report for a tool at version.

func (*Report) Add

func (r *Report) Add(name, status, detail string)

Add appends a check.

func (*Report) AddCheck

func (r *Report) AddCheck(c Check)

AddCheck appends c.

func (*Report) Err

func (r *Report) Err(name string, err error, okDetail string)

Err adds an ok check when err is nil and a failing one otherwise.

func (*Report) Failed

func (r *Report) Failed() bool

Failed reports whether any check failed.

func (*Report) Write

func (r *Report) Write(w io.Writer, asJSON bool) error

Write prints the report as aligned text, or indented JSON, and returns ErrProblems when a check failed.

Jump to

Keyboard shortcuts

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