Skip to Content
marmot
Diagnostics

Each line is one object with "schema": 1 and a kind. A command writes zero or more diagnostic lines and ends with one result line.

{"schema":1,"kind":"diagnostic","severity":"error","code":"M0002","message":"undefined: fmt.Printn",
 "span":{"file":"/src/app/main.go","line":15,"col":6,"endLine":15,"endCol":12},
 "help":["a func with a similar name exists: fmt.Println"],
 "fixes":[{"title":"use fmt.Println","edits":[{"file":"/src/app/main.go",
   "span":{"file":"/src/app/main.go","line":15,"col":6,"endLine":15,"endCol":12},"newText":"Println"}]}],
 "context":{"function":"func main()","lines":[{"line":15,"text":"\tfmt.Printn(\"x\")"}]},
 "explain":"marmot explain M0002"}
{"schema":1,"kind":"result","command":"build","ok":false,"errors":1,"warnings":0,"durationMs":310,"exitCode":1}

New fields may be added within schema 1; parsers must ignore fields they do not know.

diagnostic

FieldMeaning
severityerror, warning or note.
labelWhat is wrong at the primary span, readable on its own.
codeStable code, M0000 when there is no more specific one. See Error codes.
messageThe message, as in plain mode.
spanPrimary location. Lines and columns are 1-based, columns count bytes, endCol is exclusive. Absent location: file is empty.
labelsSecondary spans, each {span, text}.
notes, helpLists of strings.
fixesSuggested fixes, each {title, applicability, edits}; an edit is {file, span, newText} and replaces the span (an empty span inserts). applicability is machine-applicable (safe to apply unseen), maybe-incorrect (likely, check it) or has-placeholders (never apply as is). Applying every edit of one fix resolves the diagnostic.
relatedOther locations, each {span, message}, for example the declaration of a called function.
contextWhat you would open the file for: function (enclosing signature), lines (source around the span, {line, text}), types (one line definitions of the types the message names).
bundleInternal compiler errors only: a directory with the inputs for a bug report.
renderedThe human form without color, exactly what a person would see.
fullMessagePresent when message was shortened (long type names elided).
explainThe command that describes the code.

In JSON mode all errors are listed (no cap), duplicates removed, in a stable order.

result

command, ok, errors, warnings, output (the file written, on success), durationMs, exitCode.

Other commands

Other commands use the same envelope (schema, kind) with their own kinds:

CommandKinds
marmot test -jsontest per test, diagnostic per failure, result
marmot fix -jsonfix per applied fix (file, code, title, line), then diagnostic and result
marmot fmt -jsonformat per changed file (file, written), result
marmot generate -jsongenerate per directive (command, cached, outputs), result
marmot watch -jsonwatch events (build, done) around each round's own output
marmot size -jsonone size object: sections, packages, functions; -why gives why with chain
marmot bench -jsonbench per benchmark and unit, with the summaries, delta and p
marmot prof -jsonone profile object: functions, lines, and tree with -tree
marmot doctor -jsondoctor per check (check, status, detail, fix), result
marmot check -jsondiagnostic per finding with check and analyzer, check per check, result
marmot explain -json CODE{code, title, text, wrong, right, fix} on stdout

On this page

Was this page helpful?

Report an issueOpen issues