Skip to content

Instantly share code, notes, and snippets.

@griffinmyers
Last active January 6, 2018 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save griffinmyers/6ad84de5e8a6bcc8a425cb3370f2d2d3 to your computer and use it in GitHub Desktop.
Save griffinmyers/6ad84de5e8a6bcc8a425cb3370f2d2d3 to your computer and use it in GitHub Desktop.
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