MCPcopy Create free account
hub / github.com/cel-expr/cel-go / Lib

Function Lib

cel/library.go:93–112  ·  view source on GitHub ↗

Lib creates an EnvOption out of a Library, allowing libraries to be provided as functional args, and to be linked to each other.

(l Library)

Source from the content-addressed store, hash-verified

91// Lib creates an EnvOption out of a Library, allowing libraries to be provided as functional args,
92// and to be linked to each other.
93func Lib(l Library) EnvOption {
94 singleton, isSingleton := l.(SingletonLibrary)
95 return func(e *Env) (*Env, error) {
96 if isSingleton {
97 if e.HasLibrary(singleton.LibraryName()) {
98 return e, nil
99 }
100 e.libraries[singleton.LibraryName()] = singleton
101 }
102 var err error
103 for _, opt := range l.CompileOptions() {
104 e, err = opt(e)
105 if err != nil {
106 return nil, err
107 }
108 }
109 e.progOpts = append(e.progOpts, l.ProgramOptions()...)
110 return e, nil
111 }
112}
113
114// StdLibOption specifies a functional option for configuring the standard CEL library.
115type StdLibOption func(*stdLibrary) *stdLibrary

Callers 15

StringsFunction · 0.92
BindingsFunction · 0.92
SetsFunction · 0.92
TwoVarComprehensionsFunction · 0.92
ListsFunction · 0.92
MathFunction · 0.92
ProtosFunction · 0.92
EncodersFunction · 0.92
RegexFunction · 0.92
NetworkFunction · 0.92
initFunction · 0.92

Calls 4

HasLibraryMethod · 0.80
LibraryNameMethod · 0.65
CompileOptionsMethod · 0.65
ProgramOptionsMethod · 0.65

Tested by 2

initFunction · 0.74