This tool scans a directory of Go source code files to create a visualization of struct embedding in the project. This can be useful for navigating the data structures of complex projects, or identifying dependencies on particular structures.
This figure would be generated from the input file below:
package main
import (
"time"
"domain.tld/user"
)
type A struct {
B
C map[string]D
}
type B struct {
E, F string
G user.Status
Timer H
}
type D struct {
I uint64
}
type H struct {
Timer time.Ticker
J chan D
}
Install:
$ go install github.com/davidschlachter/embedded-struct-visualizer@latest
Or,
$ git clone https://github.com/davidschlachter/embedded-struct-visualizer
$ cd embedded-struct-visualizer
$ go install github.com/davidschlachter/embedded-struct-visualizer
Options:
$ embedded-struct-visualizer -h
Usage: embedded-struct-visualizer [OPTIONS] DirToScan
If the directory to scan is not provided, it defaults to './'
OPTIONS:
-out <file> path to output file (default: write to stdout)
-rankdir <direction> graphs direction (default: LR, enum: TB,LR,BT,RL)
-exclude-pkg path to exclude pkg config file, format(default: empty):
eg: exclude gopkg.in/guregu/null.v3 and models/MyStuct
prefix:null.
models.MyStuct
-v verbose logging
To open a generated DOT file, you could use Graphviz or xdot.