hcl/parse.go

23 lines
427 B
Go
Raw Normal View History

2014-08-02 18:44:14 +00:00
package hcl
import (
"fmt"
"github.com/hashicorp/hcl/hcl"
"github.com/hashicorp/hcl/json"
)
2014-08-11 23:33:28 +00:00
// Parse parses the given input and returns the root object.
2014-08-02 18:44:14 +00:00
//
// The input format can be either HCL or JSON.
2014-08-11 23:33:28 +00:00
func Parse(input string) (*hcl.Object, error) {
2014-08-02 18:44:14 +00:00
switch lexMode(input) {
case lexModeHcl:
return hcl.Parse(input)
case lexModeJson:
return json.Parse(input)
}
return nil, fmt.Errorf("unknown config format")
}