go-overview-graph

command module
v0.0.0-...-aa8457a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 26 Imported by: 0

README

go-overview-graph

A tool for displaying graph overviews of Go functions.

This is very early work-in-progress!!!

Example

// File: demo/demo.go
func Demo(flag bool, n int) {
	if flag {
		fmt.Println("Hello, World!")
	}
	fmt.Println("Oh no!")

	for _, x := range "Hello, World!" {
		fmt.Println(x)
	}

	if flag {
		fmt.Println("A")
	} else if n == 3 {
		fmt.Println("B")
	} else if n == 2 {
		fmt.Println("C")
	} else {
		fmt.Println("D")
	}

	switch n {
	case 1:
		return
	case 2:
		return
	case 3:
		return
	}
	fmt.Println("Yo")
}

Run the tool:

go run . function --pkg ./demo --function Demo | dot -Tpng -o"media/demo.png"

And we get:

Graph showing the control flow of the Demo function

Side By Side

Run:

mkdir sxs
go run . sxs --pkg ./demo --out ./sxs

And we get:

Side by side view of the demo code

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL