Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuzutech/kroki-go
Kroki Go library
https://github.com/yuzutech/kroki-go
api diagrams go golang images kroki library
Last synced: 2 months ago
JSON representation
Kroki Go library
- Host: GitHub
- URL: https://github.com/yuzutech/kroki-go
- Owner: yuzutech
- Created: 2019-02-12T18:49:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-23T15:32:13.000Z (10 months ago)
- Last Synced: 2024-06-20T19:25:25.715Z (7 months ago)
- Topics: api, diagrams, go, golang, images, kroki, library
- Language: Go
- Size: 54.7 KB
- Stars: 8
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kroki Go
[![Build Status](https://github.com/yuzutech/kroki-go/workflows/CI/badge.svg)](https://github.com/yuzutech/kroki-go/actions?query=workflow%3ACI)
A Golang library for [https://kroki.io/](https://kroki.io/).
## Usage
Create a client:
```golang
client := kroki.New(kroki.Configuration{
URL: "https://kroki.io",
Timeout: time.Second * 20,
})
```### String to diagram
Use the `FromString` function to convert a string to a diagram:
```golang
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:
```bash
echo "digraph G {Hello->World}" > hello.dot
``````golang
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:
```golang
err = client.WriteToFile("./result.svg", result)
```