{"id":13526896,"url":"https://github.com/kyoh86/richgo","last_synced_at":"2025-05-16T00:07:04.435Z","repository":{"id":37849590,"uuid":"78035735","full_name":"kyoh86/richgo","owner":"kyoh86","description":"Enrich `go test` outputs with text decorations.","archived":false,"fork":false,"pushed_at":"2024-07-25T12:44:56.000Z","size":1400,"stargazers_count":859,"open_issues_count":8,"forks_count":26,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-05-10T07:43:14.776Z","etag":null,"topics":["cli-app","enrich-outputs","go","golang","golang-tools","golang-wrapper","test"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyoh86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-01-04T17:05:57.000Z","updated_at":"2025-04-15T09:00:35.000Z","dependencies_parsed_at":"2022-07-12T17:02:32.848Z","dependency_job_id":"11e641cd-7abe-4d7a-98f9-7c4921c78ce9","html_url":"https://github.com/kyoh86/richgo","commit_stats":{"total_commits":106,"total_committers":10,"mean_commits":10.6,"dds":0.5754716981132075,"last_synced_commit":"32ccbe6aa994c4d3b7dea3e5b35d1c2b1c82fa4e"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyoh86%2Frichgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyoh86%2Frichgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyoh86%2Frichgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyoh86%2Frichgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyoh86","download_url":"https://codeload.github.com/kyoh86/richgo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442854,"owners_count":22071878,"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":["cli-app","enrich-outputs","go","golang","golang-tools","golang-wrapper","test"],"created_at":"2024-08-01T06:01:36.930Z","updated_at":"2025-05-16T00:06:59.424Z","avatar_url":"https://github.com/kyoh86.png","language":"Go","funding_links":[],"categories":["Go Tools","Go","Go工具","Go 工具","Libraries for creating HTTP middlewares","Repositories"],"sub_categories":["Routers","路由库","路由器","代码分析"],"readme":"# richgo\n\nRich-Go will enrich `go test` outputs with text decorations\n\n[![PkgGoDev](https://pkg.go.dev/badge/kyoh86/richgo)](https://pkg.go.dev/kyoh86/richgo)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kyoh86/richgo)](https://goreportcard.com/report/github.com/kyoh86/richgo)\n[![Coverage Status](https://img.shields.io/codecov/c/github/kyoh86/richgo.svg)](https://codecov.io/gh/kyoh86/richgo)\n[![Release](https://github.com/kyoh86/richgo/workflows/Release/badge.svg)](https://github.com/kyoh86/richgo/releases)\n\n[![asciicast](https://asciinema.org/a/99810.png)](https://asciinema.org/a/99810)\n\n# NOTICE (what I think about `richgo`)\n\nFor some years, I've not been using `richgo`.\nNow I don't feel much effect that a little bit of tweaking to the appearance of the test output.\nAnd It is poor method that `richgo` parses and adjusts the standard output of `go test`.\nSo now I recommend you that you do NOT use `richgo`, get use to pure `go test`, train an ability to find the error from the output and contribute to improve official `go test` if you needed.\nSome may think that I have too much faith in pure Go, but this is my honest feeling.\n\nIf you want a good suggestion for alternative tools for this one, you may find it in the [issue #57](https://github.com/kyoh86/richgo/issues/57).\n\n\n# Installation\n\n(go get):\n\n```\ngo get -u github.com/kyoh86/richgo\n```\n\n(homebrew):\n\n```\nbrew install kyoh86/tap/richgo\n```\n\n(asdf):\n\n```\nasdf plugin add richgo\nasdf install richgo 0.3.6\n```\n\n# Usage\n\n## Basic\n\n```sh\nrichgo test ./...\n```\n\n## In an existing pipeline\n\nIf your build scripts expect to interact with the standard output format of `go\ntest` (for instance, if you're using\n[go-junit-report](https://github.com/jstemmer/go-junit-report)), you'll need to\nuse the `testfilter` subcommand of `richgo`.\n\nFor example:\n\n```sh\ngo test ./... | tee \u003e(richgo testfilter) | go-junit-report\n```\n\nThis will \"tee\" the output of the standard `go test` run into a `richgo\ntestfilter` process as well as passing the original output to\n`go-junit-report`.\n\nNote that at some point this recommendation may change, as the \"go test\" tool\nmay learn how to produce a standard output format\n[golang/go#2981](https://github.com/golang/go/issues/2981) that both this tool\nand others could rely on.\n\n## alias\n\nYou can define alias so that `go test` prints rich outputs:\n\n* bash: `~/.bashrc`\n* zsh: `~/.zshrc`\n\n```\nalias go=richgo\n```\n\n## Configure\n\n### Configuration file paths\n\nIt's possible to change styles with the preference file.\nRich-Go loads preferences from the files in the following order.\n\n* `${CWD}/.richstyle`\n* `${CWD}/.richstyle.yaml`\n* `${CWD}/.richstyle.yml`\n* `${GOPATH}/.richstyle`\n* `${GOPATH}/.richstyle.yaml`\n* `${GOPATH}/.richstyle.yml`\n* `${GOROOT}/.richstyle`\n* `${GOROOT}/.richstyle.yaml`\n* `${GOROOT}/.richstyle.yml`\n* `${HOME}/.richstyle`\n* `${HOME}/.richstyle.yaml`\n* `${HOME}/.richstyle.yml`\n\nSetting the environment variable `RICHGO_LOCAL` to 1, Rich-Go loads only `${CWD}/.richstyle*`.\n\n### Configuration file format\n\n**Now Rich-Go supports only YAML formatted.**\n\n```yaml\n# Type of the label that notes a kind of each lines.\nlabelType: (long | short | none)\n\n# Style of \"Build\" lines.\nbuildStyle:\n  # Hide lines\n  hide: (true | false)\n  # Bold or increased intensity.\n  bold: (true | false)\n  faint: (true | false)\n  italic: (true | false)\n  underline: (true | false)\n  blinkSlow: (true | false)\n  blinkRapid: (true | false)\n  # Swap the foreground color and background color.\n  inverse: (true | false)\n  conceal: (true | false)\n  crossOut: (true | false)\n  frame: (true | false)\n  encircle: (true | false)\n  overline: (true | false)\n  # Fore-color of text\n  foreground: (\"#xxxxxx\" | rgb(0-256,0-256,0-256) | rgb(0x00-0xFF,0x00-0xFF,0x00-0xFF) | (name of colors))\n  # Back-color of text\n  background: # Same format as `foreground`\n\n# Style of the \"Start\" lines.\nstartStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"Pass\" lines.\npassStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"Fail\" lines.\nfailStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"Skip\" lines.\nskipStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"File\" lines.\nfileStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"Line\" lines.\nlineStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"Pass\" package lines.\npassPackageStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"Fail\" package lines.\nfailPackageStyle:\n  # Same format as `buildStyle`\n\n# A threashold of the coverage\ncoverThreshold: (0-100)\n\n# Style of the \"Cover\" lines with the coverage that is higher than coverThreshold.\ncoveredStyle:\n  # Same format as `buildStyle`\n\n# Style of the \"Cover\" lines with the coverage that is lower than coverThreshold.\nuncoveredStyle:\n  # Same format as `buildStyle`\n\n# If you want to delete lines, write the regular expressions.\nremovals:\n  - (regexp)\n# If you want to leave `Test` prefixes, set it \"true\".\nleaveTestPrefix: (true | false)\n```\n\n### Line categories\n\nRich-Go separate the output-lines in following categories.\n\n* Build:  \n  When the Go fails to build, it prints errors like this:\n\n  \u003cpre\u003e\u003ccode\u003e# github.com/kyoh86/richgo/sample/buildfail\n  sample/buildfail/buildfail_test.go:6: t.Foo undefined (type testing.T has no field or method Foo)\u003c/code\u003e\u003c/pre\u003e\n\n* Start:  \n  In the top of test, Go prints that name like this:\n\n  \u003cpre\u003e\u003ccode\u003e=== RUN   TestSampleOK/SubtestOK\u003c/code\u003e\u003c/pre\u003e\n\n* Pass:  \n  When a test is successed, Go prints that name like this:\n\n  \u003cpre\u003e\u003ccode\u003e    ---PASS: TestSampleOK/SubtestOK\u003c/code\u003e\u003c/pre\u003e\n\n* Fail:  \n  When a test is failed, Go prints that name like this:\n\n  \u003cpre\u003e\u003ccode\u003e--- FAIL: TestSampleNG (0.00s)\n  sample_ng_test.go:9: It's not OK... :(\u003c/code\u003e\u003c/pre\u003e\n\n* Skip:  \n  If there is no test files in directory or a test is skipped, Go prints that path or the name like this:\n\n  \u003cpre\u003e\u003ccode\u003e--- SKIP: TestSampleSkip (0.00s)\n  sample_skip_test.go:6:\n?     github.com/kyoh86/richgo/sample/notest  [no test files]\u003c/code\u003e\u003c/pre\u003e\n\n* PassPackage:  \n  When tests in package are successed, Go prints just:\n\n  \u003cpre\u003e\u003ccode\u003ePASS\u003c/code\u003e\u003c/pre\u003e\n\n* Fail:  \n  When a test in package are failed, Go prints just:\n\n  \u003cpre\u003e\u003ccode\u003eFAIL\u003c/code\u003e\u003c/pre\u003e\n\n* Cover:  \n  If the coverage analysis is enabled, Go prints the coverage like this:\n\n  \u003cpre\u003e\u003ccode\u003e=== RUN   TestCover05\n--- PASS: TestCover05 (0.00s)\nPASS\ncoverage: 50.0% of statements\nok  \tgithub.com/kyoh86/richgo/sample/cover05\t0.012s\tcoverage: 50.0% of statements\u003c/code\u003e\u003c/pre\u003e\n\nEach categories can be styled seperately.\n\n### Label types\n\n* Long:\n  * Build: \"BUILD\"\n  * Start: \"START\"\n  * Pass: \"PASS\"\n  * Fail: \"FAIL\"\n  * Skip: \"SKIP\"\n  * Cover: \"COVER\"\n\n* Short:\n  * Build: \"!!\"\n  * Start: \"\u003e\"\n  * Pass: \"o\"\n  * Fail: \"x\"\n  * Skip: \"-\"\n  * Cover: \"%\"\n\n* None:\n  Rich-Go will never output labels.\n\n### Default\n\n```yaml\nlabelType: long\nbuildStyle:\n  bold: true\n  foreground: yellow\nstartStyle:\n  foreground: lightBlack\npassStyle:\n  foreground: green\nfailStyle:\n  bold: true\n  foreground: red\nskipStyle:\n  foreground: lightBlack\npassPackageStyle:\n  foreground: green\n  hide: true\nfailPackageStyle:\n  bold: true\n  foreground: red\n  hide: true\ncoverThreshold: 50\ncoveredStyle:\n  foreground: green\nuncoveredStyle:\n  bold: true\n  foreground: yellow\nfileStyle:\n  foreground: cyan\nlineStyle:\n  foreground: magenta\n```\n\n## Overriding colorization detection\n\nBy default, `richgo` determines whether or not to colorize its output based\non whether it's connected to a TTY or not. This works for most use cases, but\nmay not behave as expected if you use `richgo` in a pipeline of commands, where\nSTDOUT is being piped to another command.\n\nTo force colorization, add `RICHGO_FORCE_COLOR=1` to the environment you're\nrunning in. For example:\n\n```sh\nRICHGO_FORCE_COLOR=1 richgo test ./... | tee test.log\n```\n\n## Configure to resolve a conflict with \"Solarized dark\" theme\n\nThe bright-black is used for background color in Solarized dark theme.\nRichgo uses that color for \"startStyle\" and \"skipStyle\", so \"START\" and \"SKIP\" lines can not be seen on the screen with Solarized dark theme.\n\nTo resolve that conflict, you can set another color for \"startStyle\" and \"skipStyle\" in [.richstyle](#configuration-file-paths) like below.\n\n```\nstartStyle:\n  foreground: yellow\n\nskipStyle:\n  foreground: lightYellow\n```\n\n## Getting a version of the richgo\n\nIf you want to get a version of the `richgo`, this information is embedded in the binary (since Go 1.18).\nYou can view it with go version -m, e.g. for richgo 0.3.10:\n\n```console\n$ go version -m $(command -v richgo)\n./richgo: go1.18\n\tpath\tgithub.com/kyoh86/richgo\n\tmod\tgithub.com/kyoh86/richgo\tv0.3.10\th1:iSGvcjhtQN2IVrBDhPk0if0R/RMQnCN1E/9OyAW4UUs=\n\t[...]\n```\n\nAnd just a little more advanced way (with POSIX `awk`):\n\n```console\n$ go version -m $(command -v richgo) | awk '$1 == \"mod\" \u0026\u0026 $2 == \"github.com/kyoh86/richgo\" {print $3;}'\nv0.3.10\n```\n\n# License\n\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg)](http://www.opensource.org/licenses/MIT)\n\nThis is distributed under the [MIT License](http://www.opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyoh86%2Frichgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyoh86%2Frichgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyoh86%2Frichgo/lists"}