collector/diskstats: Don't use functions from Go 1.18

Since we need to support Go 1.17, don't use `strings.Cut()` which was
introduced in Go 1.18.

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
pull/2426/head
Benoît Knecht 2 years ago committed by Johannes 'fish' Ziemke
parent a997b6096d
commit 75ceda8bb2

@ -361,9 +361,15 @@ func udevDeviceInformation(major, minor uint32) (udevInfo, error) {
scanner := bufio.NewScanner(data) scanner := bufio.NewScanner(data)
for scanner.Scan() { for scanner.Scan() {
/* TODO: After we drop support for Go 1.17, the condition below can be simplified to:
if name, value, found := strings.Cut(scanner.Text(), "="); found { if name, value, found := strings.Cut(scanner.Text(), "="); found {
info[name] = value info[name] = value
} }
*/
if fields := strings.SplitN(scanner.Text(), "=", 2); len(fields) == 2 {
info[fields[0]] = fields[1]
}
} }
return info, nil return info, nil

Loading…
Cancel
Save