diff --git a/tools/lsb_release/main.go b/tools/lsb_release/main.go index 1f27178..b6099ec 100644 --- a/tools/lsb_release/main.go +++ b/tools/lsb_release/main.go @@ -85,28 +85,28 @@ func (data *DataStruct) ReadFromFile(filePath string, validate bool) { scanner := bufio.NewScanner(file) keys := reflect.ValueOf(parseStruct).MapKeys() + handled := 0 for scanner.Scan() { line := scanner.Text() - handled := false for _, key := range keys { keyString := key.String() data := parseLine(line, keyString) if data != "" { parseStruct[keyString](data) - handled = true + handled++ break } } - if validate && !handled { - log.Fatalf("Cannot parse line '%s'", line) - } + } + if validate && len(keys) != handled { + log.Panicf("Not all needed values were extracted!") } } func parseLine(line string, regexpStr string) string { regex, err := regexp.Compile(regexpStr) if err != nil { - log.Fatalf("Cannot compile regex '%s'", regexpStr) + log.Panicf("Cannot compile regex '%s'", regexpStr) } subMatch := regex.FindStringSubmatch(line) if subMatch == nil { diff --git a/tools/lsb_release/test_data/lsb_release_1804.txt b/tools/lsb_release/test_data/lsb_release_ubuntu1804.txt similarity index 100% rename from tools/lsb_release/test_data/lsb_release_1804.txt rename to tools/lsb_release/test_data/lsb_release_ubuntu1804.txt diff --git a/version.txt b/version.txt index 320f703..a5d34d7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -version=0.3.1 \ No newline at end of file +version=0.3.2 \ No newline at end of file