Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

gohcl.EncodeIntoBody ignores optional elements #76

Closed
mitchellh opened this issue Jan 13, 2019 · 1 comment
Closed

gohcl.EncodeIntoBody ignores optional elements #76

mitchellh opened this issue Jan 13, 2019 · 1 comment

Comments

@mitchellh
Copy link

type config struct {
    Other string `hcl:"other"`
    Field bool `hcl:"field,optional"`
}

input := &config{Field: true, Other: "hello"}
fw := hclwrite.NewEmptyFile()
gohcl.EncodeIntoBody(input, fw.Body())
println(string(fw.Bytes()))

The output only contains the required fields, does not contain the optional ones (though set).

@mitchellh
Copy link
Author

My tag was missing : 😑(hcl"field" vs. hcl:"field")

So, this probably works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant