Question - Write Remain
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
I'm trying to dynamically create some HCL files from golang.
I'm trying to write the following objects
```
type Modules struct {
Modules []*Module `hcl:"module,block"`
}
type Module struct {
Name string `hcl:"name,label"`
Source string `hcl:"source"`
Options interface{} `hcl:",remain"`
}
```
Using the follow, I'm not able to generate the remaining attributes
```
func Encode(val interface{}) []byte {
f := hclwrite.NewEmptyFile()
gohcl.EncodeIntoBody(val, f.Body())
return f.Bytes()
}
```
##Output
```
module "bar" {
source = "./bar"
}
```
##Expected
```
module "bar" {
source = "./bar"
foo = "bar"
bar = ["foo", "bar"]
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the hclwrite.NewEmptyFile and gohcl.EncodeIntoBody calls shown in the issue, then reproduce the provided Modules and Module values. Trace how the `hcl:",remain"` field is handled during encoding. Done means the generated module block includes the remaining foo and bar attributes shown in the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100