hashicorp / hcl2

Former temporary home for experimental new version of HCL

Home Page:https://github.com/hashicorp/hcl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: struct field tag should support both block and optional

detailyang opened this issue · comments

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"`
}

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.

@apparentlymart Thanks. It works :)