Skip to content

Instantly share code, notes, and snippets.

@griffinmyers

griffinmyers/hcl.go

Last active Jan 6, 2018
Embed
What would you like to do?
package main
import (
"fmt"
"github.com/hashicorp/hcl"
)
func main() {
type Template struct {
Source string
Target string
}
type Config struct {
Template []Template
}
var config Config
var dynamicConfig interface{}
data := `
template {
source = "bloop"
target = "bloop"
}
template {
source = "bleep"
target = "bleep"
}
`
hcl.Decode(&config, data)
hcl.Decode(&dynamicConfig, data)
fmt.Println(config)
fmt.Println(dynamicConfig)
}
$ go run hcl/main.go
{[{bloop } { bloop} {bleep } { bleep}]}
map[template:[map[source:bloop target:bloop] map[source:bleep target:bleep]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment