{"repo":"hexops/valast","free":true,"listed":false,"github":"https://github.com/hexops/valast","clone":"git clone https://github.com/hexops/valast.git","description":"Convert Go values to their AST","language":"Go","stars":310,"topics":["go","reflect","ast","valast","go-package","golang","repr","tostring"],"license":null,"category":"dev-tools","readme_excerpt":"valast - convert Go values to their AST Valast converts Go values at runtime into their go/ast equivalent, e.g.: Prints string: What is this useful for? This can be useful for debugging and testing, you may think of it as a more comprehensive and configurable version of the fmt package's %+v and %#v formatting directives. It is similar to e.g. repr in Python. Features - Produces Go code via a go/ast , defers formatting to the best-in-class Go formatter gofumpt. - Fully handles unexported fields, types, and values (optional.) - Strong emphasis on being used for producing valid Go code that can be copy & pasted directly into e.g. tests. - Extensively tested, over 88 tests and handling numerous edge cases (such as pointers to unaddressable literal values like &\"foo\" properly, and even finding bugs in alternative packages'). - Provide custom AST representations for your types with valast.RegisterType(...) . Alternatives comparison The following are alternatives to Valast, making note of the differences we found that let us to create Valast: - github.com/davecgh/go-spew - may be inactive - Produces Go-like output, but not Go syntax. - github.com/shurcooL/go-goon (based on go-spew) - Produces valid Go syntax, but not via a go/ast . - Produces less idiomatic/terse results) - Was deprecated in favor of valast. - github.com/alecthomas/repr - Produces Go syntax, but not always valid code (e.g. can emit illegal &23 , whereas Valast will emit a valid expression valast.Addr(23).(int) ), n","default_branch":null,"files":null,"tree":[],"storefront":"/r/hexops","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/hexops/valast/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."}