hashicorp / hashicorp/hcl

embedded struct fields are not populated

Open
#136 3 comments 0 reactions 0 assignees View on GitHub
v1
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

Unmarshalling embedded struct fields works in `encoding/json` but not HCL (as of 5b7dbf7eefffea49afb3c9655d6582c72fae5fd1). Here's the code using `encoding/json`: https://play.golang.org/p/rrXXw7j8VM. The equivalent in HCL follows:

``` go
package main

import (
"fmt"

"github.com/hashicorp/hcl"
)

type Inner struct {
Dependencies []string `hcl:"dependencies"`
}

type Outer struct {
Inner

Name string `hcl:"name"`
}

func main() {
x := new(Outer)

err := hcl.Unmarshal(
[]byte(`
name = "test"
dependencies = ["a", "b", "c"]
`),
x,
)

fmt.Printf("%+v %v\n", x, err)
}
```

Would this be a contribution y'all are interested in? If you are and you could point me toward a good place to get started, I'd appreciate it :)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.