renaming splitWords to tokens

This commit is contained in:
varsha teratipally
2020-12-08 18:34:54 +00:00
parent ffc46f977d
commit 4085da817d
+6 -6
View File
@@ -55,7 +55,7 @@ func splitAfterSpace(inputChar rune) bool {
func CmdlineArgs() ([]CmdlineArg, error) {
lines, err := ReadFileIntoLines(cmdlineFilePath)
if err != nil {
return nil, fmt.Errorf("error reading the file %v, %v", cmdlineFilePath, err)
return nil, fmt.Errorf("error reading the file %s, %v", cmdlineFilePath, err)
}
if len(lines) < 1 {
return nil, fmt.Errorf("no lines are retured")
@@ -68,17 +68,17 @@ func CmdlineArgs() ([]CmdlineArg, error) {
if strings.Index(words, "\"") == 0 {
continue
}
splitsWords := strings.Split(words, "=")
if len(splitsWords) < 2 {
tokens := strings.Split(words, "=")
if len(tokens) < 2 {
var stats = CmdlineArg{
Key: splitsWords[0],
Key: tokens[0],
}
result = append(result, stats)
} else {
//remove quotes in the values
trimmedValue := strings.Trim(splitsWords[1], "\"'")
trimmedValue := strings.Trim(tokens[1], "\"'")
var stats = CmdlineArg{
Key: splitsWords[0],
Key: tokens[0],
Value: trimmedValue,
}
result = append(result, stats)