MCPcopy Create free account
hub / github.com/archlinux-de/pkgstats-cli / processIncludeLine

Method processIncludeLine

internal/pacman/parser.go:101–123  ·  view source on GitHub ↗
(line string, depth int)

Source from the content-addressed store, hash-verified

99}
100
101func (parser *parser) processIncludeLine(line string, depth int) ([]string, error) {
102 const expectedParts = 2
103 includeFileName := strings.TrimSpace(strings.SplitN(line, "=", expectedParts)[1])
104 includeFileNames, err := filepath.Glob(includeFileName)
105 if err != nil {
106 return nil, err
107 }
108
109 var allIncludedLines []string
110 for _, fileName := range includeFileNames {
111 if cachedLines, ok := parser.includeFileCache[fileName]; ok {
112 allIncludedLines = append(allIncludedLines, cachedLines...)
113 } else {
114 includedLines, err := parser.readConfigFile(fileName, depth)
115 if err != nil {
116 return nil, err
117 }
118 parser.includeFileCache[fileName] = includedLines
119 allIncludedLines = append(allIncludedLines, includedLines...)
120 }
121 }
122 return allIncludedLines, nil
123}
124
125func isCommentOrEmpty(line string) bool {
126 return line == "" || strings.HasPrefix(line, "#")

Callers 1

readConfigFileMethod · 0.95

Calls 1

readConfigFileMethod · 0.95

Tested by

no test coverage detected