MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / evalStringExpr

Function evalStringExpr

go/engine/expr/expression.go:65–88  ·  view source on GitHub ↗

evalStringExpr handles string-type expressions with interpolation.

(expression string, refs []Value)

Source from the content-addressed store, hash-verified

63 if err != nil {
64 return false, err
65 }
66 return v.AsBool(), nil
67}
68
69// evalStringExpr handles string-type expressions with interpolation.
70func evalStringExpr(expression string, refs []Value) (Value, error) {
71 if expression == "" && len(refs) == 0 {
72 return StringVal(""), nil
73 }
74 if len(refs) == 0 {
75 return StringVal(expression), nil
76 }
77
78 expression, refs = applyCastsInString(expression, refs)
79
80 if expression == "${}" && len(refs) == 1 && refs[0].Type == workflowapi.String {
81 return refs[0], nil
82 }
83
84 var b strings.Builder
85 parts := placeholderRE.Split(expression, -1)
86 for i, part := range parts {
87 b.WriteString(part)
88 if i < len(refs) {
89 b.WriteString(refs[i].AsString())
90 }
91 }

Callers 1

EvalFunction · 0.85

Calls 4

StringValFunction · 0.85
applyCastsInStringFunction · 0.85
AsStringMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected