hashicorp / hcl2

Former temporary home for experimental new version of HCL
https://github.com/hashicorp/hcl
Mozilla Public License 2.0
375 stars 64 forks source link

feat: struct field tag should support both block and optional #96

Closed detailyang closed 5 years ago

detailyang commented 5 years ago

Hello.

Now the hcl cannot set optional block via the struct tag as below:

type Block struct {}
type Object struct {
    Block    Block    `hcl:"block,block,optional"`
}
apparentlymart commented 5 years ago

Hi @detailyang,

Currently the way to specify that is to make the field have type *Block, so that gohcl can set it to nil to indicate when the nested block isn't present.

detailyang commented 5 years ago

@apparentlymart Thanks. It works :)