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

doctor

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package doctor diagnoses a gotools environment: the Go installation, the module proxy, the manifest, each managed tool, the lock, module integrity and disk use.

A Doctor only looks. It takes no lock (it asks who holds it), writes nothing, and runs every go probe with GOTOOLCHAIN=local so it never downloads a toolchain, from a scratch directory so go never reads a project's go.mod. What it finds is a Report of Check rows; a problem is a row with status warn or fail, never an error, so a caller can always render a full report.

Index

Constants

View Source
const DefaultProxyTimeout = 5 * time.Second

DefaultProxyTimeout bounds the reachability probe.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

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

Check is one row of a report. Names are dotted: the part before the dot is the group the row belongs to.

func (Check) IsIssue

func (c Check) IsIssue() bool

IsIssue reports whether the check found a problem.

type Doctor

type Doctor struct {
	Program string // the command name used in the advice, e.g. "gotools"

	Root     string
	Layout   strategy.Layout
	Manifest *manifest.Manifest
	// HasManifest reports whether the manifest file exists.
	HasManifest bool
	// Bad says why the manifest could not be loaded, "" when it could.
	Bad      string
	ModFiles modparser.Parser
	Locker   lock.Locker
	Go       gocmd.Runner
	// Offline turns the proxy check off and every probe's proxy to "off".
	Offline bool
	// Scratch is an empty directory go is run from.
	Scratch string
	// LookGo finds the go binary for the report; exec.LookPath("go") when nil.
	LookGo func() (string, error)
	// ProxyTimeout bounds the reachability probe; DefaultProxyTimeout when zero.
	ProxyTimeout time.Duration
	// contains filtered or unexported fields
}

Doctor runs the checks for one project. Everything it touches is a field, so a test supplies a fake go runner and a directory of files.

func (*Doctor) Run

func (d *Doctor) Run(ctx context.Context) Report

Run performs every check, in report order.

type Report

type Report struct {
	Checks []Check
}

Report is everything a Doctor found.

func (Report) Healthy

func (r Report) Healthy() bool

Healthy reports whether no check found a problem.

func (Report) Issues

func (r Report) Issues() int

Issues counts the checks that found a problem.

type Status

type Status string

Status is the outcome of one check.

const (
	Pass Status = "pass"
	Warn Status = "warn"
	Fail Status = "fail"
	Skip Status = "skip"
)

The statuses. Warn and fail are issues; pass and skip are not.

Jump to

Keyboard shortcuts

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