Open anandharaj-dotworld opened 2 years ago
Now it's running both sudo and non sudo
Hi. I didn't quite get what exactly have you changed? Can you make a PR please?
func parseTitle(title string) string {
strsplit := strings.Split(title, ":")
var parenthesisSplit []string
var firstSplit string
if len(strsplit) == 3 {
firstSplit = strsplit[2]
parenthesisSplit = strings.Split(firstSplit, "(")
} else {
}
if len(parenthesisSplit) > 1 {
return strings.Join(strings.Fields(parenthesisSplit[0])[1:], " ")
} else if len(parenthesisSplit) == 1 {
return strings.Join(strings.Fields(firstSplit)[1:], " ")
} else {
return " "
}
}
and
func reflectStruct(target interface{}, data string) {
values := reflect.ValueOf(target).Elem()
lines := strings.Split(data, "\n")
for i := 1; i < len(lines); i++ {
spacelessLine := strings.Replace(lines[i], " ", "", -1)
splitData := strings.Split(strings.TrimSpace(spacelessLine), ":")
fieldName := splitData[0]
var fieldValue string
if len(splitData) > 1 {
fieldValue = splitData[1]
} else {
fieldValue = ""
}
structField := values.FieldByName(fieldName)
if structField.Kind() == reflect.Invalid {
continue
} else {
setValue(structField, fieldValue)
}
}
}
This above code i changes
Ok. Send a PR and I will merge it