MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / ReadFile

Function ReadFile

ai-provider/model-runtime/loader.go:138–159  ·  view source on GitHub ↗
(dir embed.FS, name string)

Source from the content-addressed store, hash-verified

136}
137
138func ReadFile(dir embed.FS, name string) (eosc.Untyped[string, string], error) {
139
140 files, err := dir.ReadDir(name)
141 if err != nil {
142 return nil, err
143 }
144 result := eosc.BuildUntyped[string, string]()
145 for _, file := range files {
146 if file.IsDir() {
147 continue
148 }
149 if !strings.HasSuffix(file.Name(), ".yaml") && !strings.HasSuffix(file.Name(), ".svg") {
150 continue
151 }
152 data, err := dir.ReadFile(fmt.Sprintf("%s/%s", name, file.Name()))
153 if err != nil {
154 return nil, fmt.Errorf("open file %s error: %w", file.Name(), err)
155 }
156 result.Set(file.Name(), string(data))
157 }
158 return result, nil
159}

Callers 1

LoadProviderFunction · 0.85

Calls 2

NameMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected