Description
Dig lets you access and modify property values in deeply nested, unstructured maps, using dot-separated paths:
Dig: plow through nested data with ease alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view Dig: plow through nested data with ease alternatives based on common mentions on social networks and blogs.
-
fzf
A command-line fuzzy finder written in Go -
hub
wrap git commands with additional functionality to interact with github from the terminal. -
go-torch
Stochastic flame graph profiler for Go programs. -
ctop
Top-like interface (e.g. htop) for container metrics. -
goreleaser
Deliver Go binaries as fast and easily as possible -
GJSON
Get a JSON value with one line of code. -
wuzz
Interactive cli tool for HTTP inspection. -
excelize
Golang library for reading and writing Microsoft Excel (XLSX) files. -
usql
usql is a universal command-line interface for SQL databases. -
xlsx
Library to simplify reading the XML format used by recent version of Microsoft Excel in Go programs. -
godropbox
Common libraries for writing Go services/applications from Dropbox. -
resty
Simple HTTP and REST client for Go inspired by Ruby rest-client. -
godotenv
A Go port of Ruby's dotenv library (Loads environment variables from .env.) -
hystrix-go
Implements Hystrix patterns of programmer-defined fallbacks aka circuit breaker. -
gorequest
Simplified HTTP client with rich features for Go. -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
minify
Fast minifiers for HTML, CSS, JS, XML, JSON and SVG file formats. -
gojson
Automatically generate Go (golang) struct definitions from example JSON. -
panicparse
Groups similar goroutines and colorizes stack dump. -
go-funk
A modern Go utility library which provides helpers (map, find, contains, filter, chunk, reverse, ...) -
mc
Minio Client provides minimal tools to work with Amazon S3 compatible cloud storage and filesystems. -
grequests
An elegant and simple net/http wrapper that follows Python's requests library -
mergo
A helper to merge structs and maps in Golang. Useful for configuration default values, avoiding messy if-statements. -
filetype
Small package to infer the file type checking the magic numbers signature. -
spinner
Go package to easily provide a terminal spinner with options. -
sling
Go HTTP requests builder for API clients. -
boilr
A blazingly fast CLI tool for creating projects from boilerplate templates. -
coop
Cheat sheet for some of the common concurrent flows in Go. -
go-underscore
A useful collection of helpfully functional Go collection utilities. -
circuitbreaker
Circuit Breakers in Go -
jump
Jump helps you navigate faster by learning your habits. -
beaver
Beaver is a real-time messaging server. With beaver you can easily build scalable in-app notifications, realtime graphs, multiplayer games, chat applications, geotracking and more in web applications and mobile apps. -
JobRunner
Smart and featureful cron job scheduler with job queuing and live monitoring built in. -
gentleman
Full-featured plugin-driven HTTP client library. -
git-time-metric
Simple, seamless, lightweight time tracking for Git -
goreq
Minimal and simple request library for Go language. -
immortal
A *nix cross-platform (OS agnostic) supervisor -
csvtk
Another cross-platform, efficient, practical and pretty CSV/TSV toolkit -
pester
Go HTTP client calls with retries, backoff, and concurrency. -
htcat
Parallel and Pipelined HTTP GET Utility -
httpcontrol
Package httpcontrol allows for HTTP transport level control around timeouts and retries. -
mimetype
Detect mimetypes by looking at content
Get performance insights in less than 4 minutes
Do you think we are missing an alternative of Dig: plow through nested data with ease or a related project?
Popular Comparisons
README
Dig lets you access and modify property values in deeply nested, unstructured maps, using dot-separated paths:
source := make(map[string]interface{})
data := []byte(`{"a": "b", "c": {"a": "b"}}`)
json.Unmarshal(data, &source)
d := dig.NewMap(source)
log.Printf("%+v", s.Source())
// map[a:b c:map[a:b]]
s.SetValue("c.a", "42")
s.SetValue("a", "1000")
log.Printf("%+v", s.Source())
// map[a:1000 c:map[a:42]]
b, err := s.GetValue("c.a")
log.Println(b.(string))
// 42
NOTE: Still in development and mainly for educational purposes. Use with caution!
Why unstructured?
Most programming languages use (some sort of) structs for structured and maps for unstructured data. While structs are a great choice when one knows the layout of the incoming data, this may often not be the case. This is where generic maps hit the stage.
Motivation
One of the projects I worked on, was a data transformation pipeline that allowed users of the pipeline to send raw data to it, along with series of tiny rule mappings. Each rule mapping was a key-value pair, where both the key and the value would be tuples of the kind:
(nested.dotted.path.propertyToFilterUpon: filterValue), (nested.dotted.path.propertyToSetOrReplaceValueOf: newValue)
The first item of the tuple would be a dotted string, representing a nested path inside the data, e.g.:
location.address.postalCode
The value in each would be used to filter incoming data upon, or set the property under the given path, respectively. Key requirements for the pipeline were:
- agnostic to the data structure being passed to it
- resilient to change
- easy to configure (as in the example above), even by non-programmers
Advantages of dig
Upon creating a dig map, an index gets created under the hood, traversing each key until it reaches value, which cannot be traversed further (no maps, or slices). An index may look like this:
a -> val ptr,
a.b -> val.ptr
a.b.c -> val.ptr
a.b.d -> val.ptr
a.f -> val.ptr
// etc ...
Successing retrieval or value replacement with a nested path, is made using the index alone.
Creating the index is a slight overhead at the beginning, but it dramatically speeds up the look up of deeply nested paths, as it can be seen on the benchmark resutls below.
Performance Benchmarks
Listed below is the (after-index) performance of dig, when compared to manually traversing the path in a regular Go map. Lastly, GJSON - a popular JSON de/serialization library with similar capabilities gets thrown into the mix. As it can be seen, dig's reading speed is significantly higher.
Test ns. per operation
---
BenchmarkPerf/dig-8 29.1 ns/op
BenchmarkPerf/go-map-8 64.6 ns/op
BenchmarkPerf/gjson-8 201 ns/op