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

Function Lib

cel/library.go:103–123  ·  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

101// Lib creates an EnvOption out of a Library, allowing libraries to be provided as functional args,
102// and to be linked to each other.
103func Lib(l Library) EnvOption {
104 singleton, isSingleton := l.(SingletonLibrary)
105 return func(e *Env) (*Env, error) {
106 if isSingleton {
107 if e.HasLibrary(singleton.LibraryName()) {
108 return e, nil
109 }
110 e.ensureMutableLibraries()
111 e.libraries[singleton.LibraryName()] = singleton
112 }
113 var err error
114 for _, opt := range l.CompileOptions() {
115 e, err = opt(e)
116 if err != nil {
117 return nil, err
118 }
119 }
120 e.progOpts = append(e.progOpts, l.ProgramOptions()...)
121 return e, nil
122 }
123}
124
125// StdLibOption specifies a functional option for configuring the standard CEL library.
126type 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
LibraryFunction · 0.92
LibraryFunction · 0.92

Calls 5

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

Tested by 3

initFunction · 0.74