| 1 | package typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/" |
| 6 | |
| 7 | "github.com/google/cel-go/common/types/refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/" |
| 8 | "github.com/google/cel-go/common/types/traitsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/traits`/" |
| 9 | ) |
| 10 | |
| 11 | type formattablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formattable# interface { |
| 12 | formatscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formattable#format.(*stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#) |
| 13 | } |
| 14 | |
| 15 | // Format formats the value as a string. The result is only intended for human consumption and ignores errors. |
| 16 | // Do not depend on the output being stable. It may change at any time. |
| 17 | func Formatscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Format().(val refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) string { |
| 18 | var sb stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder# |
| 19 | formatToscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formatTo().(&sb, val) |
| 20 | return sb.Stringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#String().() |
| 21 | } |
| 22 | |
| 23 | func formatToscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formatTo().(sb *stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#, val refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) { |
| 24 | if fmtable, ok := val.(formattablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formattable#); ok { |
| 25 | fmtable.formatscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formattable#format.(sb) |
| 26 | return |
| 27 | } |
| 28 | // All of the builtins implement formattable. Try to deal with traits. |
| 29 | if l, ok := val.(traitsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/traits`/.Listerscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/traits`/Lister#); ok { |
| 30 | formatListscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formatList().(l, sb) |
| 31 | return |
| 32 | } |
| 33 | if m, ok := val.(traitsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/traits`/.Mapperscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/traits`/Mapper#); ok { |
| 34 | formatMapscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/formatMap().(m, sb) |
| 35 | return |
| 36 | } |
| 37 | // This could be an error, unknown, opaque or object. |
| 38 | // Unfortunately we have no consistent way of inspecting |
| 39 | // opaque and object. So we just fallback to fmt.Stringer |
| 40 | // and hope it is relavent. |
| 41 | fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Fprintf().(sb, "%s", val) |
| 42 | } |