Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blushft/go-diagrams
Create beautiful system diagrams with Go
https://github.com/blushft/go-diagrams
Last synced: 3 days ago
JSON representation
Create beautiful system diagrams with Go
- Host: GitHub
- URL: https://github.com/blushft/go-diagrams
- Owner: blushft
- License: mit
- Created: 2020-09-12T19:59:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-02T16:30:11.000Z (9 months ago)
- Last Synced: 2025-01-01T21:07:00.905Z (10 days ago)
- Language: Go
- Size: 55.2 MB
- Stars: 4,999
- Watchers: 53
- Forks: 218
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome - blushft/go-diagrams - 04 star:5.0k fork:0.2k Create beautiful system diagrams with Go (Go)
- awesome-ccamel - blushft/go-diagrams - Create beautiful system diagrams with Go (Go)
README
# Go-Diagrams
## Fast and easy application diagrams
Go-Diagrams is a loose port of [diagrams](https://github.com/mingrammer/diagrams).
## Contents
- [Features](#features)
- [Usage](#usage)## Features
Turn this:
```golang
d, err := diagram.New(diagram.Filename("app"), diagram.Label("App"), diagram.Direction("LR"))
if err != nil {
log.Fatal(err)
}dns := gcp.Network.Dns(diagram.NodeLabel("DNS"))
lb := gcp.Network.LoadBalancing(diagram.NodeLabel("NLB"))
cache := gcp.Database.Memorystore(diagram.NodeLabel("Cache"))
db := gcp.Database.Sql(diagram.NodeLabel("Database"))dc := diagram.NewGroup("GCP")
dc.NewGroup("services").
Label("Service Layer").
Add(
gcp.Compute.ComputeEngine(diagram.NodeLabel("Server 1")),
gcp.Compute.ComputeEngine(diagram.NodeLabel("Server 2")),
gcp.Compute.ComputeEngine(diagram.NodeLabel("Server 3")),
).
ConnectAllFrom(lb.ID(), diagram.Forward()).
ConnectAllTo(cache.ID(), diagram.Forward())dc.NewGroup("data").Label("Data Layer").Add(cache, db).Connect(cache, db)
d.Connect(dns, lb, diagram.Forward()).Group(dc)
if err := d.Render(); err != nil {
log.Fatal(err)
}
```Into this:
![app-diagram](images/app-diagram.png)
## Usage
```sh
go get github.com/blushft/go-diagrams
```Create a diagram:
```golang
d, err := diagram.New(diagram.Label("my-diagram"), diagram.Filename("diagram"))
if err != nil {
log.Fatal(err)
}fw := generic.Network.Firewall().Label("fw")
sw := generic.Network.Switch().Label("sw")d.Connect(fw, sw)
```Render the output:
```golang
if err := d.Render(); err != nil {
log.Fatal(err)
}
```Go-Diagrams will create a folder in the current working directory with the graphviz DOT file and any image assets.
Create an ouput image with any graphviz compatible renderer:
```sh
dot -Tpng diagram.dot > diagram.png
```