Skip to content

Instantly share code, notes, and snippets.

@aaronhurt
Last active April 17, 2018 22:05
Show Gist options
  • Save aaronhurt/a2014233e683538e1165a0e6d8578734 to your computer and use it in GitHub Desktop.
Save aaronhurt/a2014233e683538e1165a0e6d8578734 to your computer and use it in GitHub Desktop.
HCL heredoc stuff
package main
import (
"fmt"
"github.com/hashicorp/hcl"
)
const myHCL = `foo {
bar = [<<EOF
"adsf asdf"
EOF
, <<EOF
asdf asdf,
EOF
]
}`
type fooBar struct {
Foo struct {
Bar []string
}
}
func main() {
fb := &fooBar{}
err := hcl.Decode(fb, myHCL)
fmt.Printf("out: %+v\nlen: %d\nerr: %s", fb, len(fb.Foo.Bar), err)
}
@aaronhurt
Copy link
Author

Running ...

$ go run foo.go
out: &{Foo:{Bar:["adsf asdf"
 asdf asdf,
]}}
len: 2
err: %!s(<nil>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment