github.com/mitranim/repr (go): Overview  Prints Go data structures as syntactically valid Go code. Useful for code generation. The name "repr" stands for "representation" and alludes to the Python function with the same name.  Solves a problem unaddressed by https://github.com/davecgh/go-spew/spew and directly competes with https://github.com/shurcooL/go-goon  Has no dependencies outside the standard library.  Motives:  • Dumping data as code is useful for code generation and debugging.  • fmt.Sprintf("%#v") doesn't always output valid code, has no multiline mode.  • https://github.com/davecgh/go-spew/spew doesn't output valid code, has no single-line mode.  • https://github.com/shurcooL/go-goon outputs too much noise, has no single-line mode.  Supports single-line and multiline modes. Defaults to multiline.  The output looks like something you'd write by hand, and is almost exactly compliant with gofmt. Unlike gofmt, it doesn't align field values in struct literals. Use "go/format" to fix that, at a 50x performance cost:  Zero-initialized fields in structs are omitted by default (configurable).  Bytes are printed in hex notation. In multiline mode, byte arrays have 8 bytes per row:  Supports package renaming, which is useful for code generation. See Config for details.  Some of these limitations may be lifted in future versions.  • Fancy types such as "big.Int" or "time.Time" are printed as empty structs; ideally they would be printed as constructor calls.  • Funcs are treated as nil.  • Chans are treated as nil.  • Pointers to primitive types are not supported and cause a panic.  • "byte" is printed as "uint8".  • "rune" is printed as "int32".  • Runes are printed as integers, not character literals.  • Enum-style constants are not mapped back to identifers.  • On structs, only exported fields are included.  • Cyclic structures cause infinite recursion.  • Doesn't support `fmt.GoStringer` yet.  Note: pointers to composite types such as structs, arrays, slices and maps are supported by prefixing literals with "&", but Go currently doesn't support this for primitive literals.  Shell:  Example:
Keywords: code-generation|go|golang|pretty-print