Last active
January 6, 2018 18:59
-
-
Save griffinmyers/6ad84de5e8a6bcc8a425cb3370f2d2d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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