alecthomas / alecthomas/hcl

Extra remaining fields in the presence of a slice of structs

Offen
#16 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
53
Forks
12
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I ran into an issue when trying to obtain remaining fields for the example below, the second `nested` field (your) was returned as part of remaining fields.

HCL:
```
name = "hello"
nested {
name = "my"
}
nested {
name = "your"
}
message1 = "wonderful"
message2 = world
```

```
type remainStruct struct {
Name string `hcl:"name"`
Nested []*remainNested `hcl:"nested,optional"`
Remain []*Entry `hcl:",remain"`
}

type remainNested struct {
Name string `hcl:"name"`
}
```
The image below shows the third remaining field in the unmarshalled object:

![Screen Shot 2022-06-20 at 11 10 52 AM](https://user-images.githubusercontent.com/1320563/174508872-66a71d2c-7de8-49a5-baf6-713b2c86706d.png)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.