0x3d.Site
is designed for aggregating information.
check repository here
go-array
A Go package that read or set data from map, slice or json
中文 | English
Download
go get -u github.com/deatil/go-array
Get Starting
import "github.com/deatil/go-array/array"
arrData := map[string]any{
"a": 123,
"b": map[string]any{
"c": "ccc",
"d": map[string]any{
"e": "eee",
"f": map[string]any{
"g": "ggg",
},
},
"dd": []any{
"ccccc",
"ddddd",
"fffff",
},
"ff": map[any]any{
111: "fccccc",
222: "fddddd",
333: "dfffff",
},
"hh": map[int]any{
1115: "hccccc",
2225: "hddddd",
3335: map[any]string{
"qq1": "qq1ccccc",
"qq2": "qq2ddddd",
"qq3": "qq3fffff",
},
},
"kJh21ay": map[string]any{
"Hjk2": "fccDcc",
"23rt": "^hgcF5c",
},
},
}
data := array.Get(arrData, "b.d.e")
// output: eee
data := array.Get(arrData, "b.dd.1")
// output: ddddd
data := array.Get(arrData, "b.hh.3335.qq2")
// output: qq2ddddd
data := array.Get(arrData, "b.kJh21ay.Hjk2", "defValString")
// output: fccDcc
data := array.Get(arrData, "b.kJh21ay.Hjk23333", "defValString")
// output: defValString
Examples
- Exists data
var res bool = array.New(arrData).Exists("b.kJh21ay.Hjk2")
// output: true
var res bool = array.New(arrData).Exists("b.kJh21ay.Hjk12")
// output: false
- Get data
var res any = array.New(arrData).Get("b.kJh21ay.Hjk2")
// output: fccDcc
var res any = array.New(arrData).Get("b.kJh21ay.Hjk12", "defVal")
// output: defVal
- Find data
var res any = array.New(arrData).Find("b.kJh21ay.Hjk2")
// output: fccDcc
var res any = array.New(arrData).Find("b.kJh21ay.Hjk12")
// output: nil
- Use Sub to Find data
var res any = array.New(arrData).Sub("b.kJh21ay.Hjk2").Value()
// output: fccDcc
var res any = array.New(arrData).Sub("b.kJh21ay.Hjk12").Value()
// output: nil
- Use Search to Find data
var res any = array.New(arrData).Search("b", "kJh21ay", "Hjk2").Value()
// output: fccDcc
var res any = array.New(arrData).Search("b", "kJh21ay", "Hjk12").Value()
// output: nil
- Use Index to Find data
var res any = array.New(arrData).Sub("b.dd").Index(1).Value()
// output: ddddd
var res any = array.New(arrData).Sub("b.dd").Index(6).Value()
// output: nil
- Use Set to set data
arr, err := array.New(arrData).Set("qqqyyy", "b", "ff", 222)
// arr.Get("b.ff.222") output: qqqyyy
- Use SetIndex to set data
arr, err := array.New(arrData).Sub("b.dd").SetIndex("qqqyyySetIndex", 1)
// arr.Get("b.dd.1") output: qqqyyySetIndex
- Use Delete to delete data
arr, err := array.New(arrData).Delete("b", "hh", 2225)
// arr.Get("b.hh.2225") output: nil
- Use DeleteKey to delete data
arr, err := array.New(arrData).DeleteKey("b.d.e")
// arr.Get("b.d.e") output: nil
LICENSE
- The library LICENSE is
Apache2
, using the library need keep the LICENSE.
Copyright
- Copyright deatil(https://github.com/deatil).
Golang
Golang, or Go, is a statically typed programming language developed by Google. It’s known for its simplicity, performance, and support for concurrent programming. Go is widely used in cloud computing, server-side applications, and microservices.
GitHub - goyek/goyek: Task automation Go library
gommon/color at master · labstack/gommon
GitHub - blevesearch/bleve: A modern text/numeric/geo-spatial/vector indexing library for go
GitHub - schollz/progressbar: A really basic thread-safe progress bar for Golang applications
GitHub - free/concurrent-writer: Highly concurrent drop-in replacement for bufio.Writer
GitHub - mattn/go-colorable
GitHub - StudioSol/set: A simple Set data structure implementation in Go (Golang) using LinkedHashMap.
GitHub - essentialkaos/branca: Authenticated encrypted API tokens (IETF XChaCha20-Poly1305 AEAD) for Golang
Cloud Native Computing Foundation
GitHub - sakirsensoy/genv: Genv is a library for Go (golang) that makes it easy to read and use environment variables in your projects. It also allows environment variables to be loaded from the .env file.
GitHub - heetch/confita: Load configuration in cascade from multiple backends into a struct
GitHub - brianvoe/sjwt: Simple JWT Golang
GitHub - subpop/go-ini: Go package that encodes and decodes INI-files
GitHub - DylanMeeus/GoAudio: Go tools for audio processing & creation 🎶
GitHub - daviddengcn/go-colortext: Change the color of console text.
GitHub - andOTP/andOTP: [Unmaintained] Open source two-factor authentication for Android
GitHub - alfiankan/crab-config-files-templating: Dynamic configuration file templating tool for kubernetes manifest or general configuration files
GitHub - viney-shih/go-cache: A flexible multi-layer Go caching library to deal with in-memory and shared cache by adopting Cache-Aside pattern.
GitHub - TreyBastian/colourize: An ANSI colour terminal package for Go
GitHub - Evertras/bubble-table: A customizable, interactive table component for the Bubble Tea framework
GitHub - deatil/go-array: A Go package that read or set data from map, slice or json
GitHub - cometbft/cometbft: CometBFT (fork of Tendermint Core): A distributed, Byzantine fault-tolerant, deterministic state machine replication engine
GitHub - icza/session: Go session management for web servers (including support for Google App Engine - GAE).
GitHub - cristalhq/jwt: Safe, simple and fast JSON Web Tokens for Go
GitHub - lrita/cmap: a thread-safe concurrent map for go
GitHub - wzshiming/ctc: Console Text Colors - The non-invasive cross-platform terminal color library does not need to modify the Print method
GitHub - goradd/maps: map library using Go generics that offers a standard interface, go routine synchronization, and sorting
GitHub - alfiankan/teleterm: Telegram Bot Exec Terminal Command
GitHub - JeremyLoy/config: 12 factor configuration as a typesafe struct in as little as two function calls
GitHub - goraz/onion: Layer based configuration for golang
More on Golang
Programming Tips & Tricks
Code smarter, not harder—insider tips and tricks for developers.
Using Lua's Garbage Collector for Fine-Tuned Memory Management in Large Applications
#1
Leveraging Lua's Environment for Dynamic Code Execution and Security
#2
Mastering Lua's Table Manipulation: Advanced Techniques for Handling Large Data Sets
#3
Enhancing Code Readability and Debugging with Lua's Debug Library
#4
Leveraging Lua's Coroutines for Efficient Concurrency and Asynchronous Programming
#5
Leveraging Lua's Tail Call Optimization for Efficient Recursion and Avoiding Stack Overflow in Deep Recursive Functions
#6
Creating Custom Iterators in Lua for Traversing Complex Data Structures Like Graphs or Trees
#7
How to Maximize the Speed of Data Lookup in Lua Using Hash Tables and Optimized Table Management
#8
Advanced Techniques for Asynchronous Programming in Lua Using Coroutines for High-Performance Systems
#9
Mastering Efficient Memory Management in Lua with Weak Tables for Optimal Resource Utilization
#10
Error Solutions
Turn frustration into progress—fix errors faster than ever.
Visual Studio Crashes When Opening a File or Debugging a Project
#1
Visual Studio Cannot Connect to GitHub or Other Version Control System
#2
Visual Studio Freezes During Build or Debug Process
#3
Visual Studio Fails to Build Project with "Unable to Start Program" Error
#4
Visual Studio Shows "Cannot Open the Solution" Error Message When Opening a Project
#5
Visual Studio Crashes on Startup with "The application has encountered an error" Message
#6
Visual Studio Fails to Detect Changes in Files When Using Git Integration
#7
Visual Studio Crashes with "Unknown Exception" When Trying to Build Solution
#8
Visual Studio Hangs During Debugging with "Unable to Start Program" Error
#9
Visual Studio Fails to Load Solution with "The system cannot find the file specified" Error
#10
Shortcuts
The art of speed—shortcuts to supercharge your workflow.
Maximize Your Code Navigation with Cmd + Option + Left Arrow!
#1
Feel Like a Pro with Cmd + Control + D: Quickly View Definitions Like Never Before!
#2
Unlock Speed and Precision with Cmd + Shift + M: Maximize Your Productivity!
#3
Don’t Panic, Use Cmd + Option + I to Open the Developer Tools Now!
#4
Stop Wasting Time and Jump to Your File in an Instant with Cmd + Shift + O!
#5
Quickly Fix Your Code with ‘Cmd + Option + L’ for Instant Code Formatting!
#6
Transform Your Workflow with ‘Cmd + Shift + N’ to Open a New Window in No Time!
#7
Say Goodbye to Mouse: Master ‘Cmd + Shift + F’ to Search Your Entire Codebase!
#8
Struggling to Find Files? Hit ‘Cmd + P’ and Jump Right to Your File!
#9
Never Lose Your Progress Again: Use ‘Cmd + Z’ to Undo Mistakes Instantly!
#10
Made with ❤️
to provide resources in various ares.