I was wondering if anybody worked with yaml tags and schemas?
I'd like to automatically generate a bunch of Go types from a yaml
schema and validate a yaml file against that schema.
Has anyone already written this kind of `go generate` drudgery?
bonus point question:
say I have this yaml file:
#ASDF 0.1.0
#ASDF_STANDARD 0.1.0
%YAML 1.1
%TAG ! tag:stsci.edu:asdf/
--- !core/asdf-0.1.0
asdf_library: !core/software-0.1.0 {author: Space Telescope Science
Institute, homepage: 'http://github.com/spacetelescope/pyasdf',
name: pyasdf, version: 0.0.dev644}
datatype<i1: !core/ndarray-0.1.0
data: [127, -128, 0]
datatype: int8
shape: [3]
datatype<i2: !core/ndarray-0.1.0
data: [32767, -32768, 0]
datatype: int16
shape: [3]
datatype<i4: !core/ndarray-0.1.0
data: [2147483647, -2147483648, 0]
datatype: int32
shape: [3]
my_stream: !core/ndarray-0.1.0
data:
- [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
- [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
- [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]
- [3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0]
- [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]
- [5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0]
- [6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0]
- [7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0]
datatype: float64
shape: [8, 8]
...
where the core/asdf-0.1.0 schema would map to:
type ASDF struct {
Library Software `yaml:"asdf_library"`
}
if you're interested, the exact and complete schema for
core/asdf-0.1.0 is there:
https://github.com/spacetelescope/asdf-standard/blob/master/schemas/stsci.edu/asdf/core/asdf-0.1.0.yaml
I'd like to capture (and fold) all the extra 'datatype<??' and
'my_stream' keys as []struct{ Key string; Value NdArray }
so ASDF would look like:
type ASDF struct {
Library Software `yaml:"asdf_library"`
Extra ExtraData
}
type ExtraData []struct{ Key string; Value NdArray }
is this even possible?
-s
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.