{"id":13396976,"url":"https://github.com/blushft/go-diagrams","last_synced_at":"2025-05-13T00:12:35.041Z","repository":{"id":37236627,"uuid":"295016801","full_name":"blushft/go-diagrams","owner":"blushft","description":"Create beautiful system diagrams with Go","archived":false,"fork":false,"pushed_at":"2025-03-22T20:11:19.000Z","size":35710,"stargazers_count":5084,"open_issues_count":17,"forks_count":227,"subscribers_count":55,"default_branch":"master","last_synced_at":"2025-05-13T00:12:22.048Z","etag":null,"topics":[],"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/blushft.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-12T19:59:52.000Z","updated_at":"2025-05-11T00:18:30.000Z","dependencies_parsed_at":"2025-04-10T13:58:01.477Z","dependency_job_id":null,"html_url":"https://github.com/blushft/go-diagrams","commit_stats":{"total_commits":15,"total_committers":5,"mean_commits":3.0,"dds":0.2666666666666667,"last_synced_commit":"c78c821223d91bb44bde7c9aaeaf04e137566489"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blushft%2Fgo-diagrams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blushft%2Fgo-diagrams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blushft%2Fgo-diagrams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blushft%2Fgo-diagrams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blushft","download_url":"https://codeload.github.com/blushft/go-diagrams/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843219,"owners_count":21972874,"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":[],"created_at":"2024-07-30T18:01:08.643Z","updated_at":"2025-05-13T00:12:35.016Z","avatar_url":"https://github.com/blushft.png","language":"Go","funding_links":[],"categories":["Go","开源类库","Diagrams as code"],"sub_categories":["图表","Build systems"],"readme":"# Go-Diagrams\n\n## Fast and easy application diagrams\n\nGo-Diagrams is a loose port of [diagrams](https://github.com/mingrammer/diagrams).\n\n## Contents\n\n- [Features](#features)\n- [Usage](#usage)\n\n## Features\n\nTurn this:\n\n```golang\nd, err := diagram.New(diagram.Filename(\"app\"), diagram.Label(\"App\"), diagram.Direction(\"LR\"))\nif err != nil {\n    log.Fatal(err)\n}\n\ndns := gcp.Network.Dns(diagram.NodeLabel(\"DNS\"))\nlb := gcp.Network.LoadBalancing(diagram.NodeLabel(\"NLB\"))\ncache := gcp.Database.Memorystore(diagram.NodeLabel(\"Cache\"))\ndb := gcp.Database.Sql(diagram.NodeLabel(\"Database\"))\n\ndc := diagram.NewGroup(\"GCP\")\ndc.NewGroup(\"services\").\n    Label(\"Service Layer\").\n    Add(\n        gcp.Compute.ComputeEngine(diagram.NodeLabel(\"Server 1\")),\n        gcp.Compute.ComputeEngine(diagram.NodeLabel(\"Server 2\")),\n        gcp.Compute.ComputeEngine(diagram.NodeLabel(\"Server 3\")),\n    ).\n    ConnectAllFrom(lb.ID(), diagram.Forward()).\n    ConnectAllTo(cache.ID(), diagram.Forward())\n\ndc.NewGroup(\"data\").Label(\"Data Layer\").Add(cache, db).Connect(cache, db)\n\nd.Connect(dns, lb, diagram.Forward()).Group(dc)\n\nif err := d.Render(); err != nil {\n    log.Fatal(err)\n}\n```\n\nInto this:\n\n![app-diagram](images/app-diagram.png)\n\n## Usage\n\n```sh\ngo get github.com/blushft/go-diagrams\n```\n\nCreate a diagram:\n\n```golang\nd, err := diagram.New(diagram.Label(\"my-diagram\"), diagram.Filename(\"diagram\"))\nif err != nil {\n    log.Fatal(err)\n}\n\nfw := generic.Network.Firewall().Label(\"fw\")\nsw := generic.Network.Switch().Label(\"sw\")\n\nd.Connect(fw, sw)\n```\n\nRender the output:\n\n```golang\nif err := d.Render(); err != nil {\n    log.Fatal(err)\n}\n```\n\nGo-Diagrams will create a folder in the current working directory with the graphviz DOT file and any image assets.\n\nCreate an ouput image with any graphviz compatible renderer:\n\n```sh\ndot -Tpng diagram.dot \u003e diagram.png\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblushft%2Fgo-diagrams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblushft%2Fgo-diagrams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblushft%2Fgo-diagrams/lists"}