MCPcopy
hub / github.com/perkeep/perkeep / parseProvidesRequires

Function parseProvidesRequires

internal/closure/gendeps.go:101–129  ·  view source on GitHub ↗
(fi os.FileInfo, path string, f io.Reader)

Source from the content-addressed store, hash-verified

99)
100
101func parseProvidesRequires(fi os.FileInfo, path string, f io.Reader) (provides, requires []string, err error) {
102 mt := fi.ModTime()
103 depCacheMu.Lock()
104 defer depCacheMu.Unlock()
105 if ci, found := depCache[path]; found && ci.modTime.Equal(mt) {
106 return ci.provides, ci.requires, nil
107 }
108
109 scanner := bufio.NewScanner(f)
110 for scanner.Scan() {
111 l := scanner.Text()
112 if !strings.HasPrefix(l, "goog.") {
113 continue
114 }
115 m := provReqRx.FindStringSubmatch(l)
116 if m != nil {
117 if m[1] == "provide" {
118 provides = append(provides, m[2])
119 } else {
120 requires = append(requires, m[2])
121 }
122 }
123 }
124 if err := scanner.Err(); err != nil {
125 return nil, nil, err
126 }
127 depCache[path] = depCacheItem{provides: provides, requires: requires, modTime: mt}
128 return provides, requires, nil
129}
130
131// jsList prints a list of strings as JavaScript list.
132type jsList []string

Callers 1

GenDepsWithPathFunction · 0.85

Calls 7

LockMethod · 0.80
UnlockMethod · 0.80
EqualMethod · 0.80
HasPrefixMethod · 0.80
TextMethod · 0.65
ModTimeMethod · 0.45
ErrMethod · 0.45

Tested by

no test coverage detected