https://github.com/guettli/yamlutils
Go package for working with yaml
https://github.com/guettli/yamlutils
go golang yaml
Last synced: about 1 month ago
JSON representation
Go package for working with yaml
- Host: GitHub
- URL: https://github.com/guettli/yamlutils
- Owner: guettli
- License: mit
- Created: 2024-11-26T10:58:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-27T14:38:29.000Z (over 1 year ago)
- Last Synced: 2025-07-06T22:16:03.360Z (12 months ago)
- Topics: go, golang, yaml
- Language: Go
- Homepage: https://pkg.go.dev/github.com/guettli/yamlutils
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yamlutils: Go package for working with yaml
## Introduction
Imagine you have parsed a yaml like this with [sigs.k8s.io/yaml/goyaml.v3](https://pkg.go.dev/sigs.k8s.io/yaml/goyaml.v3):
```yaml
apiVersion: example.com/v1
kind: Foo
metadata:
labels:
foo: bar
spec:
level1:
level2:
level3:
field: myValue
```
You can easily get the value of the deeply nested field like this:
```go
s, found, err := NestedString(node, "spec", "level1", "level2", "level3", "field")
```
In above example `s` contains "myValue", found is true, and err is nil.
If you try to access a field which does not exit, `found` will be false.
If the value you try to get exists, but the data types does not match, `err` will be non-nil.
## API Docs
## Feedback is welcome
Please create an issue if you find a typo or if you have other ideas how to improve this package.
## Releasing
```terminal
go test ./...
RELEASE_TAG=v0.0.X
git tag $RELEASE_TAG
git push origin $RELEASE_TAG
```