• Stars
    star
    69
  • Rank 436,980 (Top 9 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🏝 JSONL Graph Tools

JSONL Graph Tools

Convenient to use with jq

Go Reference Go Report Card codecov Tests Awesome go-recipes OpenSSF Scorecard

# get https://graphviz.org/download/ 
$ go install github.com/nikolaydubina/jsonl-graph@latest

What is JSONL graph? Node has id. Edge has from and to.

{
    "id": "github.com/gin-gonic/gin",
    "can_get_github": true,
    "github_url": "https://github.com/gin-gonic/gin",
    "git_last_commit": "2021-04-21",
    "git_num_contributors": 321,
    ...
}
...
{
    "from": "github.com/gin-gonic/gin",
    "to": "golang.org/x/tools",
    ...
}

Examples

Kubernetes Pod Owners

$ kubectl get pods -o json | jq '.items[] | {to: (.kind + ":" + .metadata.name), from: (.metadata.ownerReferences[].kind + ":" + .metadata.ownerReferences[].name)}' | jsonl-graph | dot -Tsvg > k8s_pod_owners.svg

k8s_pod_owners

Large nodes and color scheme

$ cat '
{"id":"github.com/gin-gonic/gin","can_get_git":true, ... }
{"id":"github.com/gin-contrib/sse","can_get_git":true,"can_run_tests":true ... }
...
{"from":"github.com/gin-gonic/gin","to":"golang.org/x/tools"}
{"from":"github.com/gin-gonic/gin","to":"github.com/go-playground/validator/v10"}
' | jsonl-graph -color-scheme=file://$PWD/testdata/colors.json | dot -Tsvg > colored.svg

gin-color

Small nodes or only edges

$ cat '
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"bufio"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"bytes"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"encoding/json"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"errors"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"fmt"}
...
' | jsonl-graph | dot -Tsvg > small.svg

small

All Kubernetes Pod Owners with details

# add edges
$ kubectl get pods -o json | jq '.items[] | {to: .metadata.name, from: .metadata.ownerReferences[].name}' > k8s_pod_owners_details.jsonl
# add node details
$ kubectl get rs -o json | jq '.items[] | .id += .metadata.name' >> k8s_pod_owners_details.jsonl
$ kubectl get pods -o json | jq '.items[] | .id += .metadata.name' >> k8s_pod_owners_details.jsonl
# flatten objects and render
$ cat k8s_pod_owners_details.jsonl | jq '. as $in | reduce leaf_paths as $path ({}; . + { ($path | map(tostring) | join(".")): $in | getpath($path) })' | jsonl-graph | dot -Tsvg > k8s_pod_owners.svg

k8s_pod_owners_details

Rendering

Currently only Graphviz is supported. Follow progress of native Go graph rendering in github.com/nikolaydubina/go-graph-layout. Once it is ready, it will be integrated into this project.

More Repositories

1

go-recipes

🦩 Tools for Go projects
Go
3,747
star
2

go-binsize-treemap

🔍 Go binary size SVG treemap
Go
441
star
3

calendarheatmap

📅 Calendar heatmap inspired by GitHub contribution activity
Go
384
star
4

go-cover-treemap

🎄 Go code coverage to SVG treemap
Go
258
star
5

llama2.go

LLaMA-2 in native Go
Go
166
star
6

treemap

🍬 Pretty Treemaps
Go
127
star
7

go-instrument

⚡️ Automatically add Trace Spans to Go methods and functions
Go
122
star
8

go-featureprocessing

🔥 Fast, simple sklearn-like feature processing for Go
Go
107
star
9

go-graph-layout

🔮 Graph Layout Algorithms in Go
Go
78
star
10

go-cover-treemap-web

Go
77
star
11

import-graph

🕵🏻‍♂️ Collect data about your dependencies
Go
37
star
12

go-ml-benchmarks

⏱ Benchmarks of machine learning inference for Go
Go
29
star
13

watchhttp

🌺 Run command periodically and expose latest STDOUT as HTTP endpoint
Go
28
star
14

fpdecimal

🛫 Fixed-Point Decimals
Go
26
star
15

fpmoney

🧧 Fixed-Point Decimal Money
Go
23
star
16

validate

🥬 validate. simply.
Go
17
star
17

hq

🐁 happy little queue
Go
15
star
18

neuroscience-landscape

🌌 Resources on Neuroscience
12
star
19

vertfn

Go linter for Vertical Function Ordering
Go
11
star
20

smrcptr

🥞 detect mixing pointer and value method receivers
Go
10
star
21

multiline-jsonl

Read and write multiline JSONL in Go
Go
5
star
22

openapi-inline-examples

🌏 Inline OpenAPI JSON examples from filenames
Go
5
star
23

htmljson

🫐 Rich rendering of JSON as HTML in Go
Go
5
star
24

go-enum-example

Go Enum: benchmarks, examples, analysis
Go
4
star
25

htmlyaml

🐹 render YAML as HTML in Go
Go
3
star
26

rchan

rchan: Go channel through Redis List
Go
3
star
27

go-commentage

🐢 how far Go comments drifting behind
Go
2
star
28

svgpan

Pan and Zoom of SVG in your Go front-end app in browser.
Go
2
star
29

go-bench-errors

Benchmarking Go errors
Go
2
star
30

mini-awesome-cv

📝 LaTeX Awesome-CV under 200LOC
TeX
2
star
31

go-enum-encoding

Generate Go enum encoding
Go
2
star
32

consistentimports

Detect inconsistent import aliases
Go
1
star
33

go-instrument-example

Go
1
star
34

go-callsite-stats

analyse function callsites
Go
1
star
35

mdpage

🍙 CLI tool to generate one-page Markdown lists based on YAML
Go
1
star