2

I'm writing a compiler using HCL (HashiCorp Configuration Language) and I'm trying to manipulate the AST so that I can add my custom logic.

hclParseTree, err := hcl.Parse(input)
check(err)
spew.Dump(hclParseTree)

I've only managed to print all the tree elements by using go-spew.

Documentation is relatively vague and there are few supporting articles on the web. I tried to follow this one, but the syntax is deprecated (written in 2015).

How could I achieve something like this?

item := hclParseTree.Get("item")
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
  • I'm not 100% sure what you're asking, but I have a feeling you're looking for https://godoc.org/github.com/hashicorp/hcl/hcl/ast#WalkFunc – mattes Jul 27 '18 at 00:11

0 Answers0