MCPcopy Create free account
hub / github.com/crossjoin-io/crossjoin / readFile

Method readFile

api/datasets.go:320–338  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

318}
319
320func (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}

Callers 1

fetchSingleMethod · 0.95

Calls 2

fetchGitHubFileMethod · 0.95
ParseMethod · 0.45

Tested by

no test coverage detected