Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/goccy/go-graphviz
Go bindings for Graphviz
Graphviz version is here
brew install graphviz
apt-get install graphviz
circo
dot
fdp
neato
nop
nop1
nop2
osage
patchwork
sfdp
twopi
dot
svg
png
jpg
The above are the formats supported by default. You can also add custom formats.
$ go get github.com/goccy/go-graphviz
package main
import (
"bytes"
"fmt"
"log"
"github.com/goccy/go-graphviz"
)
func main() {
ctx := context.Background()
g, err := graphviz.New(ctx)
if err != nil { panic(err )}
graph, err := g.Graph()
if err != nil { panic(err) }
defer func() {
if err := graph.Close(); err != nil { panic(err) }
g.Close()
}()
n, err := graph.CreateNodeByName("n")
if err != nil { panic(err) }
m, err := graph.CreateNodeByName("m")
if err != nil { panic(err) }
e, err := graph.CreateEdgeByName("e", n, m)
if err != nil { panic(err) }
e.SetLabel("e")
var buf bytes.Buffer
if err := g.Render(ctx, graph, "dot", &buf); err != nil {
log.Fatal(err)
}
fmt.Println(buf.String())
}
path := "/path/to/dot.gv"
b, err := os.ReadFile(path)
if err != nil { panic(err) }
graph, err := graphviz.ParseBytes(b)
ctx := context.Background()
g, err := graphviz.New(ctx)
if err != nil { panic(err) }
graph, err := g.Graph()
if err != nil { panic(err) }
// create your graph
// 1. write encoded PNG data to buffer
var buf bytes.Buffer
if err := g.Render(ctx, graph, graphviz.PNG, &buf); err != nil { panic(err) }
// 2. get as image.Image instance
image, err := g.RenderImage(ctx, graph)
if err != nil { panic(err) }
// 3. write to file directly
if err := g.RenderFilename(ctx, graph, graphviz.PNG, "/path/to/graph.png"); err != nil { panic(err) }
dot
$ go install github.com/goccy/go-graphviz/cmd/dot@latest
Usage:
dot [OPTIONS]
Application Options:
-T= specify output format ( currently supported: dot svg png jpg ) (default: dot)
-K= specify layout engine ( currently supported: circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi )
-o= specify output file name
Help Options:
-h, --help Show this help message
cdt
cgraph
gvc
) via the internal/wasm
package.graphviz
package provides facade interface for all sub packages.MIT
This library embeds and uses graphviz.wasm
, which is generated based on the original source code of Graphviz. Therefore, the graphviz.wasm
follows the license adopted by Graphviz ( Eclipse Public License ).
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.