Address reviewer findings: reference hint, consumer-terms type errors, misuse exit code, immutability and parity docs
Tests / vet + fmt + tests (pull_request) Successful in 57s
Tests / vet + fmt + tests (pull_request) Successful in 57s
This commit is contained in:
@@ -87,10 +87,24 @@ func compileItem(v any) (node, error) {
|
||||
case map[string]any:
|
||||
return compileTemplate(v)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported node type %T", v)
|
||||
return nil, fmt.Errorf("a template value must be a string, a list or an object, not %s", jsonKind(v))
|
||||
}
|
||||
}
|
||||
|
||||
// jsonKind names a JSON value a template cannot hold, in the data format's own
|
||||
// terms rather than the decoding library's.
|
||||
func jsonKind(v any) string {
|
||||
switch v.(type) {
|
||||
case float64:
|
||||
return "a number"
|
||||
case bool:
|
||||
return "a boolean"
|
||||
case nil:
|
||||
return "null"
|
||||
}
|
||||
return fmt.Sprintf("%T", v)
|
||||
}
|
||||
|
||||
func compileString(s string) (node, error) {
|
||||
if err := checkTokens(s, nil); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user