Simplify trimming of quotes in readOSRelease()
Use standard library function to trim surrounding quotes from read values. This makes the code shorter and easier to read.
This commit is contained in:
parent
2fba4c2c1f
commit
f378209bf3
1 changed files with 2 additions and 8 deletions
|
|
@ -60,14 +60,8 @@ func readOSRelease(r io.Reader) (map[string]string, error) {
|
|||
}
|
||||
|
||||
key := strings.TrimSpace(parts[0])
|
||||
value := strings.TrimSpace(parts[1])
|
||||
if value[0] == '"' {
|
||||
if len(value) < 2 || value[len(value)-1] != '"' {
|
||||
return nil, errors.New("readOSRelease: invalid input")
|
||||
}
|
||||
value = value[1 : len(value)-1]
|
||||
}
|
||||
|
||||
// drop all surrounding whitespace and double-quotes
|
||||
value := strings.Trim(strings.TrimSpace(parts[1]), "\"")
|
||||
osrelease[key] = value
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue