(summaryName string, dirPath string)
| 1223 | } |
| 1224 | |
| 1225 | func getCodeExampleForSummary(summaryName string, dirPath string) ([]byte, error) { |
| 1226 | dirEntries, err := os.ReadDir(dirPath) |
| 1227 | if err != nil { |
| 1228 | return nil, err |
| 1229 | } |
| 1230 | |
| 1231 | for _, entry := range dirEntries { |
| 1232 | if entry.IsDir() { |
| 1233 | continue |
| 1234 | } |
| 1235 | |
| 1236 | fileName := entry.Name() |
| 1237 | |
| 1238 | if !strings.Contains(fileName, ".json") { |
| 1239 | continue |
| 1240 | } |
| 1241 | |
| 1242 | if strings.Contains(fileName, summaryName) { |
| 1243 | fullPath := filepath.Join(dirPath, fileName) |
| 1244 | |
| 1245 | commentInfo, err := os.ReadFile(fullPath) |
| 1246 | if err != nil { |
| 1247 | return nil, fmt.Errorf("Failed to read code example file %s error: %s ", fullPath, err) |
| 1248 | } |
| 1249 | |
| 1250 | return commentInfo, nil |
| 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | return nil, fmt.Errorf("unable to find code example file for tag %s in the given directory", summaryName) |
| 1255 | } |
no test coverage detected
searching dependent graphs…