There is a package that came out for Golang that is similar to the diagrams library in python. It generates diagrams in .dot
files and then you use Graphviz to compile them.
In the beginning of a new diagram you can specify the flow direction of the whole diagram like this:
d, err := diagram.New(
diagram.Filename("app"),
diagram.Label("App"),
diagram.Direction("LR"), // LR stands for LeftToRight
)
Then you can create a NewGroup like this:
db := diagram.NewGroup("DB")
The confusing part is per the codebase of go-diagrams we can add options to the func (g *Group) NewGroup(name string, opts ...GroupOption) *Group
. The GroupOptions are defined as such
type GroupOptions struct {
Label string
LabelJustify string
Direction string
PenColor string
BackgroundColor string
Shape string
Style string
Font Font
Attributes map[string]string
}
But whenever I make a new instance of that struct and pass it in as an option setting the Golang compiler crashes saying it cannot make conversion between types. How can I pass in at least a new Direction option to alter the direction of the children in a NewGroup()
so that my diagram looks different?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…