tl;dr go/types パッケージがめちゃくちゃ便利 https://golang.org/pkg/go/types/ https://github.com/golang/example/tree/master/gotypes gouml の紹介 Goのコードを静的解析し、PlantUMLのコードを吐くパーサを開発している。 github.com 例えばGo言語で書かれたこのソースファイルを渡すと、 package main type Human struct { Name string Age Age } type Age int func (a Age) IsAdult() bool { return a >= 20 } 以下のような PlantUML コードが生成される。 package "main" { class "Age" as main.Age <<V,Orchid>>
![GoのコードからPlantUMLコードを生成する静的解析ツールを作っている - 日記マン](https://cdn-ak-scissors.b.st-hatena.com/image/square/3b604673d01d57104517bf38397d12d6f9f95563/height=288;version=1;width=512/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fi%2Fi101330%2F20190414%2F20190414205002.png)