I have a Go project where I want to read a HCL file. This HCL file contains variables. However, I cannot parse it and I get the following error message:
Variables not allowed; Variables may not be used here., and 1 other diagnostic(s)
My Go Code:
package main
import (
"fmt"
"log"
"github.com/hashicorp/hcl/v2/hclsimple"
)
type Config struct {
Hello string `hcl:"hello"`
World string `hcl:"world"`
Message string `hcl:"message"`
}
func main() {
var config Config
err := hclsimple.DecodeFile("test.hcl", nil, &config)
if err != nil {
log.Fatalf("Failed to load configuration: %s", err)
}
fmt.Println(config.Message)
}
My HCL File
hello = "hello"
world = "world"
message = "hello ${world}"
What am I doing wrong? Is my HCL syntax perhaps not correct?