sblinch / kdl-go Goto Github PK
View Code? Open in Web Editor NEWGo library for the KDL Document Language
License: MIT License
Go library for the KDL Document Language
License: MIT License
As the following example shows, when marshalling a slice of struct, a time.Time field is not marshalled as a child node despite the struct tag.
https://go.dev/play/p/23xtZb3dWDQ
Thanks for this great library! ๐
Thanks for creating kdl-go and especially investing so much effort into the docs. Appreciated! I'm trying to move a yaml struct config to kdl structs, and haven't managed to make it work yet.
I've pasted my code below.
When I run this the following is printed:
{Defaults:{Name: Manager:false Shifts:12} Staff:[]}
Defaults
is populated with shifts = 12
as expected, but the slice of Staff is empty. Any idea what I'm doing wrong?
package main
import (
"fmt"
"github.com/sblinch/kdl-go"
)
func main() {
data := `
defaults {
shifts 12
}
team {
staff "Olivia" manager=true
staff "Ethan"
staff "Ava"
staff "Harper" shifts=10
staff "Lucas"
staff "Mason" manager=true
staff "David" shifts=4
staff "Ian" manager=true
staff "Sophia"
staff "Lily" manager=true
}
`
var cfg Config
err := kdl.Unmarshal([]byte(data), &cfg)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", cfg)
}
type Config struct {
Defaults Staff `kdl:"defaults"`
Staff []Staff `kdl:"team"`
}
type Staff struct {
Name string `kdl:"staff,multiple"`
Manager bool `kdl:"manager"`
Shifts int `kdl:"shifts"`
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.