{"id":13480960,"url":"https://github.com/alecthomas/repr","last_synced_at":"2025-04-12T01:52:18.246Z","repository":{"id":3540521,"uuid":"49776198","full_name":"alecthomas/repr","owner":"alecthomas","description":"Python's repr() for Go","archived":false,"fork":false,"pushed_at":"2025-04-02T08:31:52.000Z","size":40,"stargazers_count":164,"open_issues_count":6,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-04T23:03:25.967Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/alecthomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"COPYING","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},"funding":{"github":["alecthomas"]}},"created_at":"2016-01-16T14:17:39.000Z","updated_at":"2025-03-21T21:04:55.000Z","dependencies_parsed_at":"2024-03-29T05:27:18.273Z","dependency_job_id":"4db81623-6afd-4403-857b-cd93de964841","html_url":"https://github.com/alecthomas/repr","commit_stats":{"total_commits":57,"total_committers":9,"mean_commits":6.333333333333333,"dds":"0.22807017543859653","last_synced_commit":"71f8095bdc59cc07202ed7b0884f8dbab6997782"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Frepr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Frepr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Frepr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Frepr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas","download_url":"https://codeload.github.com/alecthomas/repr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505873,"owners_count":21115354,"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":[],"created_at":"2024-07-31T17:00:47.041Z","updated_at":"2025-04-12T01:52:18.228Z","avatar_url":"https://github.com/alecthomas.png","language":"Go","funding_links":["https://github.com/sponsors/alecthomas"],"categories":["开源类库","Go","Open source library"],"sub_categories":["调试","Debugging"],"readme":"# Python's repr() for Go [![](https://godoc.org/github.com/alecthomas/repr?status.svg)](http://godoc.org/github.com/alecthomas/repr) [![CircleCI](https://img.shields.io/circleci/project/github/alecthomas/repr.svg)](https://circleci.com/gh/alecthomas/repr)\n\nThis package attempts to represent Go values in a form that can be used almost directly in Go source\ncode.\n\nUnfortunately, some values (such as pointers to basic types) can not be represented directly in Go.\nThese values will be represented as `\u0026\u003cvalue\u003e`. eg. `\u002623`\n\n## Example\n\n```go\ntype test struct {\n  S string\n  I int\n  A []int\n}\n\nfunc main() {\n  repr.Print(\u0026test{\n    S: \"String\",\n    I: 123,\n    A: []int{1, 2, 3},\n  })\n}\n```\n\nOutputs\n\n```\n\u0026main.test{S: \"String\", I: 123, A: []int{1, 2, 3}}\n```\n\n## Why repr and not [pp](https://github.com/k0kubun/pp)?\n\npp is designed for printing coloured output to consoles, with (seemingly?) no way to disable this. If you don't want coloured output (eg. for use in diffs, logs, etc.) repr is for you.\n\n## Why repr and not [go-spew](https://github.com/davecgh/go-spew)?\n\nRepr deliberately contains much less metadata about values. It is designed to (generally) be copyable directly into source code.\n\nCompare go-spew:\n\n```go\n(parser.expression) (len=1 cap=1) {\n (parser.alternative) (len=1 cap=1) {\n  ([]interface {}) (len=1 cap=1) {\n   (*parser.repitition)(0xc82000b220)({\n    expression: (parser.expression) (len=2 cap=2) {\n     (parser.alternative) (len=1 cap=1) {\n      ([]interface {}) (len=1 cap=1) {\n       (parser.str) (len=1) \"a\"\n      }\n     },\n     (parser.alternative) (len=1 cap=1) {\n      ([]interface {}) (len=1 cap=1) {\n       (*parser.self)(0x593ef0)({\n       })\n      }\n     }\n    }\n   })\n  }\n }\n}\n```\n\nTo repr:\n\n```go\nparser.expression{\n  parser.alternative{\n    []interface {}{\n      \u0026parser.repitition{\n        expression: parser.expression{\n          parser.alternative{\n            []interface {}{\n              parser.str(\"a\"),\n            },\n          },\n          parser.alternative{\n            []interface {}{\n              \u0026parser.self{              },\n            },\n          },\n        },\n      },\n    },\n  },\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Frepr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecthomas%2Frepr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Frepr/lists"}