{"id":17760819,"url":"https://github.com/kociumba/stackparse","last_synced_at":"2025-11-03T18:56:03.952Z","repository":{"id":259288810,"uuid":"877017562","full_name":"kociumba/stackparse","owner":"kociumba","description":"utility to parse go stack traces and make them more readable","archived":false,"fork":false,"pushed_at":"2024-10-24T20:39:45.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T08:15:16.052Z","etag":null,"topics":["go","golang","minimal-dependencies","pack","parser","stacktrace"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/kociumba/stackparse","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/kociumba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-10-23T00:12:18.000Z","updated_at":"2024-11-05T20:21:53.000Z","dependencies_parsed_at":"2024-10-24T04:58:16.987Z","dependency_job_id":"0e9ef38e-74ea-41ab-8ced-a742cccd0fa4","html_url":"https://github.com/kociumba/stackparse","commit_stats":null,"previous_names":["kociumba/stackparse"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kociumba%2Fstackparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kociumba%2Fstackparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kociumba%2Fstackparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kociumba%2Fstackparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kociumba","download_url":"https://codeload.github.com/kociumba/stackparse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246644098,"owners_count":20810687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["go","golang","minimal-dependencies","pack","parser","stacktrace"],"created_at":"2024-10-26T19:13:28.631Z","updated_at":"2025-10-28T13:19:10.004Z","avatar_url":"https://github.com/kociumba.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stackparse\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b3c8e57d263348939c207fd2f5f6e6f0)](https://app.codacy.com/gh/kociumba/stackparse/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n\nA Go library for parsing and formatting stack traces with powerful customization options. This library makes debugging crashes and deliberate stack dumps more manageable by providing beautifully formatted stack traces with customizable styling.\n\n## Installation\n\n```bash\ngo get github.com/kociumba/stackparse\n```\n\n## Basic Usage\n\nThe simplest way to use stackparse is to capture and parse a stack trace:\n\n```go\npackage main\n\nimport (\n    \"os\"\n    \"runtime\"\n    \"github.com/kociumba/stackparse\"\n)\n\nfunc main() {\n    // Create a buffer for the stack trace\n    buf := make([]byte, 1\u003c\u003c16)\n    \n    // Capture the stack trace\n    runtime.Stack(buf, true)\n    \n    // Parse and format the stack trace\n    parsed := stackparse.Parse(buf)\n    // modify the buffer in place with:\n    stackparse.ParseStatic(\u0026buf)\n    \n    // Write to stderr (or any other output)\n    os.Stderr.Write(parsed)\n    // if using stackparse.ParseStatic(), simply write from the buffer\n    os.Stderr.Write(buf)\n}\n```\n\n\u003e [!IMPORTANT]\n\u003e Right now stackparse does not parse the reason given when when calling `panic()`, but this is planned for the next release.\n\n## Configuration Options\n\nstackparse provides several configuration options to customize the output:\n\n\u003e [!NOTE]\n\u003e Default settings are: Colorize: true, Simple: true, Theme: stackparse.DefaultTheme()\n\n### Colorization\n\nControl whether the output includes ANSI color codes:\n\n```go\n// Disable coloring the output\nparsed := stackparse.Parse(buf, stackparse.WithColor(false))\n```\n\n### Simple Mode\n\nToggle between simple and detailed output formats (shortens both the function names and file paths):\n\n```go\n// Disable simple mode for more detailed output, does not guarantee that the formatting will be correct in all cases\nparsed := stackparse.Parse(buf, stackparse.WithSimple(false))\n```\n\n## Theming\n\nstackparse uses [lipgloss](https://github.com/charmbracelet/lipgloss) for styling and provides powerful theming capabilities.\n\n### Using the Default Theme\n\nThe default theme provides a color scheme based on the [catppuccin theme](https://catppuccin.com/).\n\n```go\n// Stackparse uses the default theme without having to pass it in\nparsed := stackparse.Parse(buf)\n\n// You can get the default theme like this\ndefaultTheme := stackparse.DefaultTheme()\n```\n\n### Custom Themes\n\nYou can create custom themes by modifying the default theme or creating a new one from scratch:\n\n```go\n// Create a custom theme based on the default\nmyTheme := stackparse.DefaultTheme()\n\n// overwrite the default styles compleatly\nmyTheme.Goroutine = lipgloss.NewStyle().\n    Bold(true).\n    Foreground(lipgloss.Color(\"#ff0000\")) // Red goroutine labels\n\nmyTheme.Function = lipgloss.NewStyle().\n    Foreground(lipgloss.Color(\"#00ff00\")). // Green function names\n    Italic(true)\n\n// or build on top of the default theme\nmyTheme.Repeat = myTheme.Repeat.Faint(true).Blink(true) \n\n// Apply the custom theme\nparsed := stackparse.Parse(buf, stackparse.WithTheme(myTheme))\n```\n\n### Theme Components\n\nThe Theme struct provides the following customizable components:\n\n- `Goroutine`: Styling for goroutine headers\n- `Function`: Styling for function names\n- `Args`: Styling for function arguments\n- `File`: Styling for file paths\n- `Line`: Styling for line numbers\n- `CreatedBy`: Styling for \"created by\" sections\n- `Repeat`: Styling for repeated stack frames\n\n### Custom Style Disabling\n\nYou can control how styles are disabled when colors are turned off with:\n\n```go\nmyTheme := stackparse.DefaultTheme()\n\n// Custom disable function\nmyTheme.SetDisableStylesFunc(func(t *stackparse.Theme) {\n    // Keep bold formatting but remove colors\n    t.Goroutine = t.Goroutine.UnsetForeground()\n    t.Function = t.Function.UnsetForeground()\n    t.Repeat = t.Repeat.UnsetBlink().UnsetFeint()\n    \n    // Keep some styling intact\n    // everything else remains unchanged\n})\n\nparsed := stackparse.Parse(buf, \n    stackparse.WithTheme(myTheme),\n    stackparse.WithColor(false), // This will trigger the custom disable function\n)\n```\n\n## Output Example\n\nWhen using the default theme, your stack trace will be formatted like this:\n\n![default styling](/assets/image.png)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request with anything: fixes, demos, improvements, etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkociumba%2Fstackparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkociumba%2Fstackparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkociumba%2Fstackparse/lists"}