hashicorp / hashicorp/hcl

Question: correct way to get children?

Open
#175 0 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

### Go Example
```go
package main

import (
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/hcl"
"github.com/hashicorp/hcl/hcl/ast"
)

func main() {
hclStr := []byte(`
a "b" "c" {
d = "e"
f "g" {
h = "i"
}
}
`)
objRoot, _ := hcl.ParseBytes(hclStr)
objList, _ := objRoot.Node.(*ast.ObjectList)
spew.Dump(objList.Filter("a", "b", "c"))
spew.Dump(objList.Filter("a", "b", "c").Children())
}
```

### Expected behavior
I would think it would return the nested `f` object.
What should have happened?

### Actual behavior
I get no objects/items returned.

### Steps to reproduce
1. run the example above

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.