embedded-struct-visualizer

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 8 Imported by: 0

README

Visualize a hierarchy of embedded Go structs

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.

Example

This figure would be generated from the input file below:

visualizer screenshot

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
}

Usage

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)
  -v           verbose logging

To open a generated DOT file, you could use Graphviz or xdot.

Documentation

Overview

The embedded-struct-visualizer command builds a Graphviz DOT file representing the tree of embedded structs in a Go project

Jump to

Keyboard shortcuts

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