(dir embed.FS, name string)
| 136 | } |
| 137 | |
| 138 | func 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 | } |
no test coverage detected