Skip to content
/ godia Public

GoDia creates a Dia diagram (open source diagram editor) of the structs and their relationships from a Go project directory that can then be edited within Dia.

License

Notifications You must be signed in to change notification settings

klaxxon/godia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDia

GoDia is a simple go program that takes golang files and produces a .dia diagram (for the popular Dia open source diagram editor) of the structs and their references. The diagram below is generated by running the program on itself. I manually placed and colored the structs, but goepc will read in the original .dia diagram before it creates a new one so it can maintain the positional and color settings.

Self Diagram (colors added for demo)

This has some bugs and is a work in progress. It has been working for some large Go projects, but has issues if I include vendor directories.

Features:

  • Uses DIAs UML diagram
  • Uses "implements" connections between the field and associated struct type
  • The "stereotype" is set to the package name
  • All fields and their types are shown
  • C++ comments on the filed lines are included
  • If the .dia file already exists when this is run, it will attempt to keep the position, color and size the same.

Running


To simply generate the start of the diagram above....
From within the godia directory:

$> go run *.go -i ./ -o self
This will generate a self.dia file you can open in dia, an open source diagram editor. It places all of the structs on top of each other so you will need to move then around. However, if you save your changes and re-run, it should create a new self.dia but respect the positions you set on the existing structs (hopefully).

For large projects with packages you do not want (like vendor) simply add a comma delimited line of directories to ignore.

$> go run *.go -i ./ -o self -ignore vendor,.vscode,ignoredir

Issues

Including one of my vendor directories (4000+ structs!) does create some parsing issues I have not fixed.

TODO

  • Have GoDia take the actial go files and simply find all dependencies. This is currently a little issue since I still do not firmly grasp the dependency rules for modules within the Go compiler.
  • Add optional receiver methods

About

GoDia creates a Dia diagram (open source diagram editor) of the structs and their relationships from a Go project directory that can then be edited within Dia.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages