Skip to content

yuzutech/kroki-go

Repository files navigation

kroki-go

Build Status

A Golang library for https://kroki.io/.

Usage

Create a client:

client := kroki.New(kroki.Configuration{
		URL:     "https://demo.kroki.io",
		Timeout: time.Second * 20,
	})

String to diagram

Use the FromString function to convert a string to a diagram:

result, err := client.FromString("digraph G {Hello->World}", kroki.Graphviz, kroki.Svg)

Here, result contains the image returned by Kroki as a string.

File to diagram

Use the FromFile function to convert a file to a diagram:

echo "digraph G {Hello->World}" > hello.dot
result, err := client.FromFile("./hello.dot", kroki.Graphviz, kroki.Svg)

Write to a file

use the WriteToFile function to write a result to a file:

err = client.WriteToFile("./result.svg", result)