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

Function createConfigMap

internal/pacman/config_map.go:32–53  ·  view source on GitHub ↗
(lines []string)

Source from the content-addressed store, hash-verified

30}
31
32func createConfigMap(lines []string) configMap {
33 cm := newConfigMap()
34 var sectionName string
35 const expectedParts = 2
36 for _, line := range lines {
37 line = strings.TrimSpace(line)
38 if isSection(line) {
39 sectionName = extractSectionName(line)
40 continue
41 }
42
43 keyValuePair := strings.SplitN(line, "=", expectedParts)
44 key := strings.TrimSpace(keyValuePair[0])
45
46 value := ""
47 if len(keyValuePair) == expectedParts {
48 value = strings.TrimSpace(keyValuePair[1])
49 }
50 cm.Add(sectionName, key, value)
51 }
52 return cm
53}
54
55func isSection(line string) bool {
56 return len(line) > 2 && strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]")

Callers 1

parseConfigFileMethod · 0.85

Calls 4

newConfigMapFunction · 0.85
isSectionFunction · 0.85
extractSectionNameFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected