All Projects → hexops → valast

hexops / valast

Licence: other
Convert Go values to their AST

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to valast

cache
LRU-based cache package for Go.
Stars: ✭ 25 (-90.04%)
Mutual labels:  go-package
yode
Yode - Focused Code Editing
Stars: ✭ 28 (-88.84%)
Mutual labels:  ast
StatePrinter
Automating unit testing and ToString() coding
Stars: ✭ 89 (-64.54%)
Mutual labels:  tostring
js-ziju
Compile javascript to LLVM IR, x86 assembly and self interpreting
Stars: ✭ 112 (-55.38%)
Mutual labels:  ast
vast
A simple tool for vlang, generate v source file to AST json file
Stars: ✭ 23 (-90.84%)
Mutual labels:  ast
lpegrex
Parse programming languages syntax into an AST using PEGs with ease (LPeg Extension).
Stars: ✭ 32 (-87.25%)
Mutual labels:  ast
define-property
Define a non-enumerable property on an object.
Stars: ✭ 21 (-91.63%)
Mutual labels:  reflect
tsquery-playground
Playground for TSQuery
Stars: ✭ 30 (-88.05%)
Mutual labels:  ast
parse-function
(!! moved to tunnckoCore/opensource multi-package repository !!) 🔱 Parse a function into an object using espree, acorn or babylon parsers. Extensible through Smart Plugins.
Stars: ✭ 37 (-85.26%)
Mutual labels:  ast
ast ninja
The Elixir AST explorer
Stars: ✭ 59 (-76.49%)
Mutual labels:  ast
hxjsonast
Parse JSON into position-aware AST with Haxe!
Stars: ✭ 28 (-88.84%)
Mutual labels:  ast
impast
A library for package AST importing
Stars: ✭ 26 (-89.64%)
Mutual labels:  ast
asty
Abstract Syntax Tree (AST) Data Structure
Stars: ✭ 28 (-88.84%)
Mutual labels:  ast
node-typescript-parser
Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.
Stars: ✭ 121 (-51.79%)
Mutual labels:  ast
xast
Extensible Abstract Syntax Tree
Stars: ✭ 32 (-87.25%)
Mutual labels:  ast
ruby ast visualizer
🌲 Ruby AST Visualizer. Based on Parser.
Stars: ✭ 28 (-88.84%)
Mutual labels:  ast
verilogAST-cpp
C++17 implementation of an AST for Verilog code generation
Stars: ✭ 14 (-94.42%)
Mutual labels:  ast
ast-builder
Build your ASTs directly from code
Stars: ✭ 18 (-92.83%)
Mutual labels:  ast
esvalid
confirm that a SpiderMonkey format AST represents an ECMAScript program
Stars: ✭ 24 (-90.44%)
Mutual labels:  ast
astra
Astra: a Java tool for analysing and refactoring Java source code
Stars: ✭ 35 (-86.06%)
Mutual labels:  ast

valast - convert Go values to their AST Hexops logo

Go Reference

Go CI codecov Go Report Card

Valast converts Go values at runtime into their go/ast equivalent, e.g.:

x := &foo.Bar{
    a: "hello world!",
    B: 1.234,
}
fmt.Println(valast.String(x))

Prints string:

&foo.Bar{a: "hello world!", B: 1.234}

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').

Alternatives comparison

The following are alternatives to Valast, making note of the differences we found that let us to create Valast:

You may also wish to look at autogold and go-cmp, which aim to solve the "compare Go values in a test" problem.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].