Documentation
¶
Overview ¶
Package doctor implements the diagnostic check runner shared by the `ctm doctor` CLI and the `GET /api/doctor` HTTP endpoint.
The CLI formats ok/warn/err Check slices as coloured lines; the HTTP endpoint JSON-encodes the same slice. Adding a new check means appending one function here — both surfaces pick it up without edits.
Index ¶
Constants ¶
const ( StatusOK = "ok" StatusWarn = "warn" StatusErr = "err" )
Status enumerates the three check outcomes surfaced to both CLI and UI. Values are the wire form — do not rename without bumping the API.
Variables ¶
This section is empty.
Functions ¶
func LookupBinary ¶
LookupBinary resolves a named binary on PATH. Exposed so the CLI formatter (cmd/doctor.go) can share the exact same probe logic rather than shelling out a second time.
Types ¶
type Check ¶
type Check struct {
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
Remediation string `json:"remediation,omitempty"`
}
Check is the single result row. JSON tags are the /api/doctor wire contract; Remediation is optional and omitted when empty.
func Run ¶
Run executes every diagnostic check and returns the results in display order. All checks respect ctx cancellation; Run returns immediately with whatever it has accumulated if ctx expires.
cfg is the already-loaded user config. A zero-valued Config is legal: checks that depend on user-configurable lists (required_env, required_in_path) simply report "not configured".