INNER CODE UNIT · Go
fail
stacklok/toolhive · cmd/help/openapi-normalize/main.go:75
func fail(err error) {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
func decodeDocument(input []byte, extension string) (map[string]any, error) {
var document map[string]any
if extension == ".yaml" || extension == ".yml" {
if err := yaml.Unmarshal(input, &document); err != nil {
return nil, fmt.Errorf("decode YAML: %w", err)
}
} else if err := json.Unmarshal(input, &document); err != nil {
return nil, fmt.Errorf("decode JSON: %w", err)
}
if document == nil {
return nil, fmt.Errorf("OpenAPI document must be an object")
}
return document, nil