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.
-
项目文档
🚀Vite+Vue3+Gin拥有AI辅助的基础开发平台,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
create-go-app
✨ A complete and self-contained solution for developers of any qualification to create a production-ready project with backend (Go), frontend (JavaScript, TypeScript) and deploy automation (Ansible, Docker) by running only one CLI command. -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness.
InfluxDB high-performance time series database

Do you think we are missing an alternative of Dig: plow through nested data with ease or a related project?
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