Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "log"
- "os"
- "github.com/hashicorp/hcl"
- )
- const (
- EXAMPLE_HCL = `config = "/etc/test.conf"`
- )
- type HCLConfig struct {
- ConfigFile string `hcl:"config"`
- }
- func main() {
- cfg := &HCLConfig{}
- hclTree, err := hcl.Parse(EXAMPLE_HCL)
- if err != nil {
- os.Exit(1)
- }
- // how to modify tree to override config field
- if err := hcl.DecodeObject(&cfg, hclTree); err != nil {
- os.Exit(1)
- }
- log.Printf("%+vn", cfg)
- }
Add Comment
Please, Sign In to add comment