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

Function Lib

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

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

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

Tested by 2

initFunction · 0.74