(path string)
| 318 | } |
| 319 | |
| 320 | func (api *API) readFile(path string) (io.Reader, error) { |
| 321 | log.Printf("reading file `%s`", path) |
| 322 | urlPath, _ := url.Parse(path) |
| 323 | if urlPath != nil { |
| 324 | if strings.Contains(path, "api.github.com") { |
| 325 | contents, err := api.fetchGitHubFile(path) |
| 326 | if err != nil { |
| 327 | return nil, fmt.Errorf("read file: %w", err) |
| 328 | } |
| 329 | return bytes.NewReader(contents), nil |
| 330 | } |
| 331 | return nil, fmt.Errorf("unsupported path: %s", path) |
| 332 | } |
| 333 | contents, err := ioutil.ReadFile(path) |
| 334 | if err != nil { |
| 335 | return nil, fmt.Errorf("read file: %w", err) |
| 336 | } |
| 337 | return bytes.NewReader(contents), nil |
| 338 | } |
no test coverage detected