MCPcopy Create free account
hub / github.com/cloudwan/gohan / NewMiniGoValue

Function NewMiniGoValue

extension/gohanscript/value.go:51–77  ·  view source on GitHub ↗

NewMiniGoValue makes a MiniGoValue value

(param interface{})

Source from the content-addressed store, hash-verified

49
50//NewMiniGoValue makes a MiniGoValue value
51func NewMiniGoValue(param interface{}) (*MiniGoValue, error) {
52 code, ok := param.(string)
53 if !ok {
54 return nil, nil
55 }
56 if code == "" {
57 return nil, nil
58 }
59 if code[0] != '$' {
60 return nil, nil
61 }
62 minigoCode := code[1:]
63 if minigoCode[0] == '{' {
64 minigoCode = minigoCode[1:]
65 }
66 if minigoCode[len(minigoCode)-1] == '}' {
67 minigoCode = minigoCode[:len(minigoCode)-1]
68 }
69 minigo, err := CompileExpr(minigoCode)
70 if err != nil {
71 return nil, err
72 }
73 t := &MiniGoValue{
74 minigo: minigo,
75 }
76 return t, nil
77}
78
79//Constant represents donburi consntant.
80type Constant struct {

Callers 2

NewValueFunction · 0.85
CacheTemplateFunction · 0.85

Calls 1

CompileExprFunction · 0.85

Tested by

no test coverage detected