I have a program which parses yamls file to an objects (structs). I use the following repo to do it
https://github.com/go-yaml/yaml
for example in the file I have:
dependency :
- name: ui
type: runner
cwd: /ui
install:
- name: api
group: test
And I use the following struct for it
type Dependency struct {
Name string
Type string
CWD string
Install []Install
//here I have the issue
Requires ?
}
type Install struct {
Name string
Group string
}
Now I have two few issue with a bit complex struct.
This is the entry which could be inside the Dependency struct and this is how it look in the yaml file
requires:
- name: db
- type: mongo
but it also can be
requires:
- name: db
- name: rst
- name: test
- name: test2
Since it have multiple name properties how should I got build this struct
In addition I've field in the yaml
_type-version: "1.0.0"
when I put it inside struct like following I got error since I use -
type TypeVer struct{
_Type-version string
}
How to overcome this?