mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-18 22:41:00 -06:00
658ae9fe75
Previously we had constants defined for AST type names. These were used in error messages in various places. The original goal was to make error messages consistent, however, this approach made it difficult to locate the source of the error in code.
16 lines
392 B
Go
16 lines
392 B
Go
// Copyright 2016 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ast
|
|
|
|
import (
|
|
"reflect"
|
|
"strings"
|
|
)
|
|
|
|
// TypeName returns a human readable name for the AST element type.
|
|
func TypeName(x interface{}) string {
|
|
return strings.ToLower(reflect.Indirect(reflect.ValueOf(x)).Type().Name())
|
|
}
|