{"repo":"sanity-io/litter","free":true,"listed":false,"github":"https://github.com/sanity-io/litter","clone":"git clone https://github.com/sanity-io/litter.git","description":"Litter is a pretty printer library for Go data structures to aid in debugging and testing.","language":"Go","stars":1654,"topics":["golang","go","testing","logging","library","mit-license"],"license":"MIT","category":"dev-tools","readme_excerpt":"Litter Litter is a pretty printer library for Go data structures to aid in debugging and testing. --- Litter is provided by Sanity: The Headless CMS Construction Kit --- Litter named for the fact that it outputs literals , which you litter your output with. As a side benefit, all Litter output is syntactically correct Go. You can use Litter to emit data during debug, and it's also really nice for \"snapshot data\" in unit tests, since it produces consistent, sorted output. Litter was inspired by Spew, but focuses on terseness and readability. Basic example This: will output: Use in tests Litter is a great alternative to JSON or YAML for providing \"snapshots\" or example data. For example: The first run will use Litter to write the data to testdata.txt . On subsequent runs, the test will compare the data. Since Litter always provides a consistent view of a value, you can compare the strings directly. Circular references Litter detects circular references or aliasing, and will replace additional references to the same object with aliases. For example: will output: Installation Quick start Add this import line to the file you're working in: To dump a variable with full newlines, indentation, type, and aliasing information, use Dump or Sdump : litter.Dump(value, ...) Dumps the data structure to STDOUT. litter.Sdump(value, ...) Returns the dump as a string Configuration You can configure litter globally by modifying the default litter.Config litter.Options Allows you to configure a l","default_branch":null,"files":null,"tree":[],"storefront":"/r/sanity-io","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sanity-io/litter/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}