{"id":48528750,"url":"https://github.com/nuvrel/diag","last_synced_at":"2026-04-07T23:30:29.183Z","repository":{"id":344956249,"uuid":"1173683040","full_name":"nuvrel/diag","owner":"nuvrel","description":"Terminal diagnostic messages with source code context for Go.","archived":false,"fork":false,"pushed_at":"2026-03-27T22:55:14.000Z","size":238,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-28T05:13:08.081Z","etag":null,"topics":["cli","diagnostics","go","golang","terminal"],"latest_commit_sha":null,"homepage":"https://diag.nuvrel.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuvrel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-05T16:28:27.000Z","updated_at":"2026-03-27T22:54:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nuvrel/diag","commit_stats":null,"previous_names":["nuvrel/diag"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nuvrel/diag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuvrel%2Fdiag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuvrel%2Fdiag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuvrel%2Fdiag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuvrel%2Fdiag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuvrel","download_url":"https://codeload.github.com/nuvrel/diag/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuvrel%2Fdiag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31533822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","diagnostics","go","golang","terminal"],"created_at":"2026-04-07T23:30:27.059Z","updated_at":"2026-04-07T23:30:29.178Z","avatar_url":"https://github.com/nuvrel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003ediag 🩺\u003c/h1\u003e\n  \u003cp\u003eTerminal diagnostic messages with source code context for Go.\u003c/p\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/nuvrel/diag/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/nuvrel/diag\" alt=\"Release\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/nuvrel/diag/actions/workflows/build.yaml\"\u003e\u003cimg src=\"https://github.com/nuvrel/diag/actions/workflows/build.yaml/badge.svg\" alt=\"Build\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/nuvrel/diag/actions/workflows/test.yaml\"\u003e\u003cimg src=\"https://github.com/nuvrel/diag/actions/workflows/test.yaml/badge.svg\" alt=\"Test\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/nuvrel/diag\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/nuvrel/diag.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/nuvrel/diag\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/nuvrel/diag\" alt=\"Go Report Card\"\u003e\u003c/a\u003e\n    \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"License: MIT\"\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./.github/output.png\" alt=\"Examples\" width=\"500\" /\u003e\n\u003c/p\u003e\n\n## Install\n\n```sh\ngo get github.com/nuvrel/diag\n```\n\n## Usage\n\nBuild each diagnostic separately, then hand them all to the printer at once. `Print` accepts any number of diagnostics and renders them in order, with spacing between each one.\n\n```go\nsrc := []byte(`func add(a, b int) int {\n\treturn a + c\n}`)\n\nd := diag.NewError(\"undefined: c\").\n\tCode(\"E001\").\n\tDetail(\n\t\t\"Variables must be declared before use. The identifier `c` was not found in any enclosing scope.\",\n\t\t\"If you meant to use `b`, note that it was declared in the same function signature.\",\n\t).\n\tSnippet(diag.NewSnippet(src).\n\t\tFile(\"math.go\").\n\t\tFrom(2, 13).\n\t\tTo(2, 14).\n\t\tMessage(\"c is not defined\")).\n\tHelp(\"did you mean to use b?\")\n\np := diag.NewPrinter(os.Stdout, diag.DefaultConfig())\n\nif err := p.Print(d); err != nil {\n\treturn fmt.Errorf(\"printing diagnostics: %w\", err)\n}\n```\n\n## Config\n\nThe `Config` struct controls every aspect of the output. Use the `Default*` helpers for the parts you want to keep as-is and override only what you need.\n\n```go\ncfg := diag.Config{\n\tProfile:        colorprofile.Detect(os.Stdout, os.Environ()),\n\tTheme:          diag.DefaultTheme(),\n\tCharacters:     diag.DefaultCharacters(),\n\tPrefixes:       diag.DefaultPrefixes(),\n\tSeverityLabels: diag.DefaultSeverityLabels(),\n}\n```\n\n**Profile**\n\nControls color output. Detected automatically from the terminal by default. Set to `colorprofile.Ascii` or `colorprofile.NoTTY` to disable colors:\n\n```go\ncfg := diag.Config{\n\tProfile: colorprofile.Ascii,\n\t// ...\n}\n```\n\n**Theme**\n\nControls the style of every visual element. All fields accept a `lipgloss.Style`:\n\n```go\ncfg := diag.Config{\n\t// ...\n\tTheme: diag.Theme{\n\t\tError:   lipgloss.NewStyle().Foreground(lipgloss.Color(\"#EB4268\")).Bold(true),\n\t\tWarning: lipgloss.NewStyle().Foreground(lipgloss.Color(\"#E8FE96\")).Bold(true),\n\t\tMessage: lipgloss.NewStyle().Bold(true),\n\t\tDetail:  lipgloss.NewStyle().Foreground(lipgloss.Color(\"#CCCCCC\")),\n\t\tHelp:    lipgloss.NewStyle().Foreground(lipgloss.Color(\"#00D7FF\")),\n\t\tNote:    lipgloss.NewStyle().Foreground(lipgloss.Color(\"#858392\")),\n\t\tMuted:   lipgloss.NewStyle().Foreground(lipgloss.Color(\"#858392\")),\n\t},\n}\n```\n\n**Characters**\n\nControls every character used in the output. Defaults use Unicode box-drawing characters and symbols. Swap to ASCII alternatives for environments that cannot render Unicode:\n\n```go\ncfg := diag.Config{\n\t// ...\n\tCharacters: diag.Characters{\n\t\tTop:      \",\",\n\t\tMid:      \"|\",\n\t\tBot:      \"'\",\n\t\tDash:     \"-\",\n\t\tDot:      \".\",\n\t\tHintHelp: \"\u003e\",\n\t\tHintNote: \"~\",\n\t},\n}\n```\n\n`HintHelp` and `HintNote` are prepended to `help` and `note` lines. Set either to `\"\"` to remove the prefix character entirely.\n\n**Prefixes**\n\nControls the label text for `help` and `note` lines:\n\n```go\ncfg := diag.Config{\n\t// ...\n\tPrefixes: diag.Prefixes{\n\t\tHelp: \"ajuda\",\n\t\tNote: \"observação\",\n\t},\n}\n```\n\n**SeverityLabels**\n\nControls the label text for each severity level:\n\n```go\ncfg := diag.Config{\n\t// ...\n\tSeverityLabels: diag.SeverityLabels{\n\t\tError:   \"erro\",\n\t\tWarning: \"aviso\",\n\t},\n}\n```\n\n**DetailPad**\n\nControls the number of spaces used to indent `.Detail()` text (default `2`):\n\n```go\ncfg := diag.Config{\n\t// ...\n\tDetailPad: 4,\n}\n```\n\n**Margin**\n\nControls the number of leading spaces added to every line of output that has content, leaving blank lines untouched. Useful for visually nesting diagnostics within other content (default `0`):\n\n```go\ncfg := diag.Config{\n\t// ...\n\tMargin: 4,\n}\n```\n\n**SkipHeader / SkipDetail**\n\nControls whether the header or detail section is suppressed. Use these when the caller renders its own header or detail and only needs the remaining parts from the printer:\n\n```go\ncfg := diag.Config{\n\t// ...\n\tSkipHeader: true,\n\tSkipDetail: true,\n}\n```\n\n**HeaderFunc**\n\nControls the header rendering. When non-nil, replaces the default renderer. It receives the severity, label, error code (may be empty), and message, and must return a fully rendered string:\n\n```go\ncfg := diag.Config{\n\t// ...\n\tHeaderFunc: func(sev diag.Severity, label, code, message string) string {\n\t\theader := strings.ToUpper(label)\n\n\t\tif code != \"\" {\n\t\t\theader += \"[\" + code + \"]\"\n\t\t}\n\n\t\treturn header + \": \" + message\n\t},\n}\n```\n\n**DetailFunc**\n\nControls the detail rendering. When non-nil, replaces the default renderer. It receives the detail paragraphs and must return a fully rendered string:\n\n```go\ncfg := diag.Config{\n\t// ...\n\tDetailFunc: func(detail []string) string {\n\t\treturn strings.Join(detail, \"\\n\\n\")\n\t},\n}\n```\n\n## API\n\n**Diagnostics**\n\n- `NewError(msg)` / `NewWarning(msg)` creates a new diagnostic\n- `.Code(code)` attaches an error code shown in the header\n- `.Detail(paragraphs...)` sets the detail body rendered as indented prose below the header\n- `.Snippet(s)` attaches a source code snippet\n- `.Help(text)` appends a help note\n- `.Note(text)` appends an informational note\n- `.Severity()` returns the severity level of the diagnostic\n- `.Message()` returns the primary message of the diagnostic\n\nRegardless of the order methods are chained, the output always renders in a fixed sequence: header, detail, snippets, then hints (help and note).\n\n**Snippets**\n\n- `NewSnippet(src)` creates a snippet from a byte slice\n- `.File(name)` sets the file name shown above the snippet\n- `.From(line, col)` / `.To(line, col)` sets the highlighted range\n- `.Message(text)` sets the label shown under the highlight\n- `.Pad(n)` sets how many context lines to show around the highlight (default 2)\n- `.TabWidth(n)` sets the tab width used for alignment (default 4)\n- `.Margin(n)` adds leading spaces to every line inside the snippet block\n\n## Stability\n\n`diag` is pre-1.0. The API is functional and tested, but minor versions may introduce breaking changes as the library grows. If you depend on it, pin to a specific version and review the changelog before upgrading.\n\n## Roadmap\n\nThese are the features planned before a stable 1.0 release:\n\n- [ ] **Syntax highlighting** for snippet blocks, likely powered by [chroma](https://github.com/alecthomas/chroma), with configurable language detection and theme support\n- [ ] **Text wrapping** for detail and hint content, using terminal width detection with a configurable fallback column limit\n- [ ] **List blocks** for attaching structured bullet-point content to a diagnostic\n- [ ] **Table blocks** for displaying tabular data inline in the output\n\nHave a feature in mind that isn't listed here? [Open a feature request](https://github.com/nuvrel/diag/issues/new?template=feature_request.md).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuvrel%2Fdiag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuvrel%2Fdiag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuvrel%2Fdiag/lists"}