{"id":17910866,"url":"https://github.com/inancgumus/prettyslice","last_synced_at":"2025-03-23T22:33:15.357Z","repository":{"id":57487429,"uuid":"150119835","full_name":"inancgumus/prettyslice","owner":"inancgumus","description":"Pretty prints slices to any io.Writer: I created this package to teach slices in my Go course.","archived":false,"fork":false,"pushed_at":"2019-03-05T22:09:11.000Z","size":191,"stargazers_count":64,"open_issues_count":0,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-06-19T19:30:30.813Z","etag":null,"topics":["go","golang","slice","slices","teaching-tool"],"latest_commit_sha":null,"homepage":"","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/inancgumus.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}},"created_at":"2018-09-24T14:55:06.000Z","updated_at":"2024-04-19T03:08:02.000Z","dependencies_parsed_at":"2022-09-01T23:02:49.478Z","dependency_job_id":null,"html_url":"https://github.com/inancgumus/prettyslice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inancgumus%2Fprettyslice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inancgumus%2Fprettyslice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inancgumus%2Fprettyslice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inancgumus%2Fprettyslice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inancgumus","download_url":"https://codeload.github.com/inancgumus/prettyslice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221919688,"owners_count":16901826,"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","slice","slices","teaching-tool"],"created_at":"2024-10-28T19:35:03.838Z","updated_at":"2024-10-28T19:35:04.741Z","avatar_url":"https://github.com/inancgumus.png","language":"Go","readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/inancgumus/prettyslice)](https://goreportcard.com/report/github.com/inancgumus/prettyslice) [![Go Doc](https://img.shields.io/badge/godoc-Reference-brightgreen.svg?style=flat)](https://godoc.org/github.com/inancgumus/prettyslice)\n\n# Pretty Slice Printer\nIt pretty prints **any type of** slices to any [io.Writer](https://golang.org/pkg/io/#Writer) with adjustable **coloring** features.\n\n## Example\n\n```go\npackage main\n\nimport s \"github.com/inancgumus/prettyslice\"\n\nfunc main() {\n\tnums := []int{1, 3, 5, 2, 4, 8}\n\todds := nums[:3]\n\tevens := nums[3:]\n\n\tnums[1], nums[3] = 9, 6\n\ts.Show(\"nums\", nums)\n\ts.Show(\"odds : nums[:3]\", odds)\n\ts.Show(\"evens: nums[3:]\", evens)\n}\n```\n\n### Output:\n![](https://github.com/inancgumus/prettyslice/raw/master/slices.png)\n\n## Example #2 — Render Colorless\n\n```go\npackage main\n\nimport s \"github.com/inancgumus/prettyslice\"\n\nfunc main() {\n\t// Render colorless output to a file\n\tf, _ := os.Create(\"out.txt\")\n\tdefer f.Close()\n\n\tnums := []int{1, 3, 5, 2, 4, 8}\n\n\ts.Writer = f\n\ts.Colors(false)\n\ts.Show(\"nums\", nums)\n}\n```\n\n---\n\n## Printing Options\n\n* **Writer:** Control where to draw the output. _Default: colors.Output (It's like os.Stdout but with colors)._\n* **PrintBacking:** Whether to print the backing array. _Default: false._\n* **PrettyByteRune:** Prints the bytes and runes as characters instead of numbers. _Default: true._\n* **MaxPerLine:** Maximum number of slice items on a line. _Default: 5._\n* **MaxElements:** Limits the number of elements printed. 0 means printing all elements. _Default: 0._\n* **Width:** Number of space characters (_padding_) between the header message and the slice details like len, cap and ptr. _Default: 45._\n* **NormalizePointers:** Prints the addresses of the slice elements as if they're contiguous. It basically normalizes by the element type size. See the source code for more information. _Default: false._\n* **PrintHex:** Prints the pointers as hexadecimals. _Default: false._\n* **PrintBytesHex:** Prints byte elements as hex digits. Overrides  the PrettyByteRune option for byte values. _Default: false._\n* **PrintElementAddr:** Prints the element addresses. _Default: false._\n\n## Coloring Options\n\n* **ColorHeader:** Sets the color for the header. _Default: color.New(color.BgHiBlack, color.FgMagenta, color.Bold)._\n* **ColorSlice:** Sets the color for the slice elements. _Default: color.New(color.FgCyan)._\n* **ColorBacker:** Sets the color for the backing array elements. _Default: color.New(color.FgHiBlack)._\n* **ColorIndex:** Sets the color for the index numbers. _Default: ColorBacker._\n* **ColorAddr:** Sets the color for the element addresses. _Default: ColorBacker._\n\nHave fun!\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Financgumus%2Fprettyslice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Financgumus%2Fprettyslice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Financgumus%2Fprettyslice/lists"}