applyCastsInCode processes cast functions in non-string expressions.
(expression string, refs []Value)
| 129 | }) |
| 130 | resolved = strings.TrimSpace(resolved) |
| 131 | |
| 132 | return parseAndEval(resolved, targetType) |
| 133 | } |
| 134 | |
| 135 | // applyCastsInCode processes cast functions in non-string expressions. |
| 136 | func applyCastsInCode(expression string, refs []Value) (string, []Value) { |
| 137 | result := make([]Value, len(refs)) |
| 138 | copy(result, refs) |
| 139 | |
| 140 | for { |
| 141 | loc := castOverrideRE.FindStringSubmatchIndex(expression) |
| 142 | if loc == nil { |
| 143 | break |
| 144 | } |
| 145 | castName := expression[loc[2]:loc[3]] |
| 146 | plIdx := len(placeholderRE.FindAllStringIndex(expression[:loc[0]], -1)) |
| 147 | targetType := castNameToDataType(castName) |
| 148 | result[plIdx] = result[plIdx].Cast(targetType) |
| 149 | expression = expression[:loc[0]] + "${}" + expression[loc[1]:] |
| 150 | } |
no test coverage detected