{"id":17993919,"url":"https://github.com/jimeh/go-render","last_synced_at":"2025-04-04T05:14:00.157Z","repository":{"id":228254514,"uuid":"773502922","full_name":"jimeh/go-render","owner":"jimeh","description":"A simple and flexible solution to render a value to a io.Writer using different formats based on a format string argument.","archived":false,"fork":false,"pushed_at":"2024-03-25T22:03:15.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T00:09:55.177Z","etag":null,"topics":["go","golang","golang-module","golang-package","marshaling","render"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/jimeh/go-render","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/jimeh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-03-17T20:41:18.000Z","updated_at":"2024-03-25T03:08:53.000Z","dependencies_parsed_at":"2024-06-21T12:55:00.557Z","dependency_job_id":"48c395ad-051a-4039-a148-f5ad97b02454","html_url":"https://github.com/jimeh/go-render","commit_stats":null,"previous_names":["jimeh/go-render"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimeh%2Fgo-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimeh","download_url":"https://codeload.github.com/jimeh/go-render/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123087,"owners_count":20887261,"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","golang-module","golang-package","marshaling","render"],"created_at":"2024-10-29T20:13:28.890Z","updated_at":"2025-04-04T05:14:00.104Z","avatar_url":"https://github.com/jimeh.png","language":"Go","readme":"\u003ch1 align=\"center\"\u003e\n  go-render\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003e\n    A simple and flexible solution to render a value to a \u003ccode\u003eio.Writer\u003c/code\u003e\n    using different formats based on a format string argument.\n  \u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/jimeh/go-render/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/jimeh/go-render?label=release\" alt=\"GitHub tag (latest SemVer)\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/jimeh/go-render\"\u003e\u003cimg src=\"https://img.shields.io/badge/%E2%80%8B-reference-387b97.svg?logo=go\u0026logoColor=white\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-render/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-raw/jimeh/go-render.svg?style=flat\u0026logo=github\u0026logoColor=white\" alt=\"GitHub issues\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-render/pulls\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-pr-raw/jimeh/go-render.svg?style=flat\u0026logo=github\u0026logoColor=white\" alt=\"GitHub pull requests\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codeclimate.com/github/jimeh/go-render\"\u003e\u003cimg src=\"https://img.shields.io/codeclimate/coverage/jimeh/go-render.svg?logo=code%20climate\" alt=\"Coverage\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jimeh/go-render/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/jimeh/go-render.svg?style=flat\" alt=\"License Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nDesigned around using a custom type/struct to render your output. Thanks to Go's\nmarshaling interfaces, you get JSON, YAML, and XML support almost for free.\nWhile plain text output is supported by the type implementing `io.Reader`,\n`io.WriterTo`, `fmt.Stringer`, and `error` interfaces, or by simply being a type\nwhich can easily be type cast to a byte slice.\n\nOriginally intended to easily implement CLI tools which can output their data as\nplain text, as well as JSON/YAML with a simple switch of a format string. But it\ncan just as easily render to any `io.Writer`.\n\nThe package is designed to be flexible and extensible with a sensible set of\ndefaults accessible via package level functions. You can create your own\n`Renderer` for custom formats, or create new handlers that support custom\nformats.\n\n## Import\n\n```go\nimport \"github.com/jimeh/go-render\"\n```\n\n## Usage\n\nBasic usage to render a value to various formats into a `io.Writer`:\n\n```go\nversion := \u0026Version{Version: \"1.2.1\", Stable: true, Latest: false}\n\nerr = render.Pretty(w, \"text\", version)\n// 1.2.1 (stable: true, latest: false)\n\nerr = render.Pretty(w, \"json\", version)\n// {\n//   \"version\": \"1.2.1\",\n//   \"latest\": false,\n//   \"stable\": true\n// }\n\nerr = render.Compact(w, \"json\", version)\n// {\"version\":\"1.2.1\",\"latest\":false,\"stable\":true}\n\nerr = render.Pretty(w, \"yaml\", version)\n// version: 1.2.1\n// latest: false\n// stable: true\n\nerr = render.Pretty(w, \"xml\", version)\n// \u003cversion latest=\"false\" stable=\"true\"\u003e1.2.1\u003c/version\u003e\n```\n\nThe above assumes the following `Version` struct:\n\n```go\ntype Version struct {\n    Version string `json:\"version\" yaml:\"version\" xml:\",chardata\"`\n    Latest  bool   `json:\"latest\" yaml:\"latest\" xml:\"latest,attr\"`\n    Stable  bool   `json:\"stable\" yaml:\"stable\" xml:\"stable,attr\"`\n}\n\nfunc (v *Version) String() string {\n    return fmt.Sprintf(\n        \"%s (stable: %t, latest: %t)\", v.Version, v.Stable, v.Latest,\n    )\n}\n```\n\n## Documentation\n\nPlease see the\n[Go Reference](https://pkg.go.dev/github.com/jimeh/go-render#section-documentation)\nfor documentation and further examples.\n\n## License\n\n[MIT](https://github.com/jimeh/go-render/blob/main/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimeh%2Fgo-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimeh%2Fgo-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimeh%2Fgo-render/lists"}