MCPcopy Create free account
hub / github.com/GuyARoss/orbit / ReadFile

Method ReadFile

cmd/dependgraph/reader.go:31–67  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

29}
30
31func (o dependgraph) ReadFile(path string) error {
32 file, err := os.Open(path)
33
34 if err != nil {
35 return err
36 }
37
38 defer file.Close()
39
40 confirmMode := false
41
42 scanner := bufio.NewScanner(file)
43 for scanner.Scan() {
44 splitLine := strings.Split(scanner.Text(), " ")
45
46 if !confirmMode {
47 if splitLine[1] != "graph" {
48 return fmt.Errorf("received invalid mode type '%s'", splitLine[2])
49 }
50
51 confirmMode = true
52 continue
53 }
54
55 if o[splitLine[0]] == nil {
56 o[splitLine[0]] = make([]string, 0)
57 }
58
59 o[splitLine[0]] = append(o[splitLine[0]], splitLine[1])
60 }
61
62 if err := scanner.Err(); err != nil {
63 return err
64 }
65
66 return nil
67}

Callers 10

DocFromFileFunction · 0.80
TestWriteFileFunction · 0.80
WriteFileFunction · 0.80
parseStaticDocumentFunction · 0.80
setupDocFunction · 0.80
dependgraph.goFile · 0.80
parseStaticDocumentFunction · 0.80
setupDocFunction · 0.80
parseStaticDocumentFunction · 0.80
setupDocFunction · 0.80

Calls 1

CloseMethod · 0.65

Tested by 1

TestWriteFileFunction · 0.64