The swiss knife
to deal with the hassle of unstructured data
.
This module is already ready-for-production
and the astrokube organization already
take advantage of it for our internal projects.
- Easy integration: It's straightforward to be integrated with your current developments.
Use go get to retrieve the library to add it to your GOPATH workspace, or project's Go module dependencies.
go get -u github.com/astrokube/pathifier
To update the library use go get -u to retrieve the latest version of it.
go get -u github.com/astrokube/pathifier
You could specify a concrete version of this module as It's shown on the below. Replace x.y.z by the desired version.
module github.com/<org>/<repository>
require (
github.com/astrokube/pathifier vX.Y.Z
)
- Go 1.19+
A rich and growing set of examples of usage of this module can be found in folder examples
.
package main
import (
"strings"
"github.com/astrokube/pathify"
)
var peopleArray = []any{
map[string]any{
"firstname": "John",
"lastname": "Doe",
"age": 29,
},
map[string]any{
"firstname": "Jane",
"lastname": "Moe",
"age": 30,
},
}
func main() {
p := pathify.Load[[]any](peopleArray).Set(
"[1].lastname", "Doe",
"[0].firstname", "Wendy",
"[2].firstname", "Cindy",
"[1].firstname", strings.ToUpper,
)
b, _ := p.YAML()
println(string(b))
b, _ = p.JSON()
println(string(b))
}
Output
- age: 29
firstname: Wendy
lastname: Doe
- age: 30
firstname: JANE
lastname: Doe
- firstname: Cindy
[{"age":29,"firstname":"Wendy","lastname":"Doe"},{"age":30,"firstname":"JANE","lastname":"Doe"},{"firstname":"Cindy"}]
See the contributing documentation.