Skip to content

Slice graph uses graphviz in order to pretty print slices for you.

License

Notifications You must be signed in to change notification settings

jbszczepaniak/slicegraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slicegraph

Slice graph uses graphviz in order to make you understand what happens underneath your slices.

How to use that?

package main

import (
	"bytes"
	"fmt"

	"github.com/jbszczepaniak/slicegraph/slicegraph"
)

func main() {
	var a []int
	b := []int{1, 2, 3, 4, 5, 6, 7, 8}
	c := b[4:6]
	d := b[6:]
	e := make([]int, len(b))
	copy(e, b)

	var by []byte
	buff := bytes.NewBuffer(by)
	err := slicegraph.AsGraph(map[string][]int{
		"a": a,
		"b": b,
		"c": c,
		"d": d,
		"e": e,
	}, buff)
	if err != nil {
		panic(err)
	}

	fmt.Println(buff)
}

Run above program and redirect the output to the file

go run main.go > example.svg
open example.svg

Examine the results 🕵🏼‍♂️

slices

About

Slice graph uses graphviz in order to pretty print slices for you.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages