Skip to content

Logiraptor/valuegraph

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

valuegraph

Package valuegraph produces a graph representation of any Go value.

See the docs or some examples.

Install

Add "github.com/tcard/valuegraph" to your import list and then go get.

The OpenSVG function function, and some methods on Graph, depend on Graphviz's dot command to be installed in your system.

## Examples

This:

valuegraph.OpenSVG(&Point{1, 2})

Opens this in a browser:

captura de pantalla 2015-06-22 a las 14 07 21

You also have the valuegraph.Make function, which returns a struct you can call less side-effectful methods on.

Recursive data types are handled OK:

v := &List{1, &List{2, &List{3, nil}}}
v.Next.Next.Next = v
valuegraph.OpenSVG(v)

captura de pantalla 2015-06-22 a las 14 05 41

Try it with complex data structures. For example, the go/ast representation of this code:

package main

// Main function.
func main() {
	x := 5
	if x < 3 {
		fmt.Println("x < 3")
	}
}

Yields a certainly big, but navigable, representation. Here's part of it:

captura de pantalla 2015-06-22 a las 16 01 05

Note the path to each element as tooltip (the text that appears when hovering over a node).

About

Package valuegraph produces a graph representation of any Go value.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%