{"id":13493933,"url":"https://github.com/goccy/go-graphviz","last_synced_at":"2025-04-29T18:48:28.449Z","repository":{"id":39714654,"uuid":"236740615","full_name":"goccy/go-graphviz","owner":"goccy","description":"Go bindings for Graphviz","archived":false,"fork":false,"pushed_at":"2025-01-09T09:52:24.000Z","size":5322,"stargazers_count":770,"open_issues_count":17,"forks_count":72,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-10T19:08:19.474Z","etag":null,"topics":["dot-language","go","golang","golang-library","graphviz"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goccy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-01-28T13:24:09.000Z","updated_at":"2025-03-28T12:37:11.000Z","dependencies_parsed_at":"2023-12-13T02:25:50.216Z","dependency_job_id":"808d18f1-1feb-4ca2-a03c-f12be78e739b","html_url":"https://github.com/goccy/go-graphviz","commit_stats":{"total_commits":73,"total_committers":8,"mean_commits":9.125,"dds":0.09589041095890416,"last_synced_commit":"865af036ddbb745c4424bbd2fdaa9a75668cf0d4"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Fgo-graphviz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Fgo-graphviz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Fgo-graphviz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goccy%2Fgo-graphviz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goccy","download_url":"https://codeload.github.com/goccy/go-graphviz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251563575,"owners_count":21609754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dot-language","go","golang","golang-library","graphviz"],"created_at":"2024-07-31T19:01:20.126Z","updated_at":"2025-04-29T18:48:28.418Z","avatar_url":"https://github.com/goccy.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-graphviz [![Go](https://github.com/goccy/go-graphviz/workflows/Go/badge.svg)](https://github.com/goccy/go-graphviz/actions) [![GoDoc](https://godoc.org/github.com/goccy/go-graphviz?status.svg)](https://pkg.go.dev/github.com/goccy/go-graphviz) \n\nGo bindings for Graphviz\n\n\u003cimg src=\"https://user-images.githubusercontent.com/209884/90976476-64e84000-e578-11ea-9596-fb4a7d3b11a6.png\" width=\"400px\"\u003e\u003c/img\u003e\n\n# Features\n\nGraphviz version is [here](./graphviz.version)\n\n- Pure Go Library\n- No need to install Graphviz library ( ~`brew install graphviz`~ or ~`apt-get install graphviz`~ )\n  - The Graphviz library has been converted to WebAssembly (WASM) and embedded it, so it works consistently across all environments\n- Supports encoding/decoding for DOT language\n- Supports custom renderer for custom format\n- Supports setting graph properties in a type-safe manner\n\n## Supported Layout\n\n`circo` `dot` `fdp` `neato` `nop` `nop1` `nop2` `osage` `patchwork` `sfdp` `twopi`\n\n## Supported Format\n\n`dot` `svg` `png` `jpg`\n\nThe above are the formats supported by default. You can also add custom formats.\n\n# Installation\n\n```bash\n$ go get github.com/goccy/go-graphviz\n```\n\n# Synopsis\n\n## 1. Write DOT Graph in Go\n\n```go\npackage main\n\nimport (\n  \"bytes\"\n  \"fmt\"\n  \"log\"\n\n  \"github.com/goccy/go-graphviz\"\n)\n\nfunc main() {\n  ctx := context.Background()\n  g, err := graphviz.New(ctx)\n  if err != nil { panic(err )}\n\n  graph, err := g.Graph()\n  if err != nil { panic(err) }\n  defer func() {\n    if err := graph.Close(); err != nil { panic(err) }\n    g.Close()\n  }()\n  n, err := graph.CreateNodeByName(\"n\")\n  if err != nil { panic(err) }\n\n  m, err := graph.CreateNodeByName(\"m\")\n  if err != nil { panic(err) }\n\n  e, err := graph.CreateEdgeByName(\"e\", n, m)\n  if err != nil { panic(err) }\n  e.SetLabel(\"e\")\n\n  var buf bytes.Buffer\n  if err := g.Render(ctx, graph, \"dot\", \u0026buf); err != nil {\n    log.Fatal(err)\n  }\n  fmt.Println(buf.String())\n}\n```\n\n## 2. Parse DOT Graph\n\n```go\npath := \"/path/to/dot.gv\"\nb, err := os.ReadFile(path)\nif err != nil { panic(err) }\ngraph, err := graphviz.ParseBytes(b)\n```\n\n## 3. Render Graph\n\n```go\nctx := context.Background()\ng, err := graphviz.New(ctx)\nif err != nil { panic(err) }\n\ngraph, err := g.Graph()\nif err != nil { panic(err) }\n\n// create your graph\n\n// 1. write encoded PNG data to buffer\nvar buf bytes.Buffer\nif err := g.Render(ctx, graph, graphviz.PNG, \u0026buf); err != nil { panic(err) }\n\n// 2. get as image.Image instance\nimage, err := g.RenderImage(ctx, graph)\nif err != nil { panic(err) }\n\n// 3. write to file directly\nif err := g.RenderFilename(ctx, graph, graphviz.PNG, \"/path/to/graph.png\"); err != nil { panic(err) }\n```\n\n# Tool\n\n## `dot`\n\n### Installation\n\n```bash\n$ go install github.com/goccy/go-graphviz/cmd/dot@latest\n```\n\n### Usage\n\n```\nUsage:\n  dot [OPTIONS]\n\nApplication Options:\n  -T=         specify output format ( currently supported: dot svg png jpg ) (default: dot)\n  -K=         specify layout engine ( currently supported: circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi )\n  -o=         specify output file name\n\nHelp Options:\n  -h, --help  Show this help message\n```\n\n# How it works\n\n1. Generates bindings between Go and C from [Protocol Buffers file](./internal/wasm/bind.proto).\n2. Builds graphviz.wasm on the [docker container](./internal/wasm/build/Dockerfile).\n3. Uses Graphviz functionality from a sub-packages ( `cdt` `cgraph` `gvc` ) via the `internal/wasm` package. \n4. `graphviz` package provides facade interface for all sub packages.\n\n# License\n\nMIT\n\nThis 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](https://graphviz.org/license) ( Eclipse Public License ).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoccy%2Fgo-graphviz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoccy%2Fgo-graphviz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoccy%2Fgo-graphviz/lists"}