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>
This commit is contained in:
Benoît Knecht 2022-06-14 20:02:10 +02:00 committed by Johannes 'fish' Ziemke
parent a997b6096d
commit 75ceda8bb2
1 changed files with 6 additions and 0 deletions

View File

@ -361,9 +361,15 @@ func udevDeviceInformation(major, minor uint32) (udevInfo, error) {
scanner := bufio.NewScanner(data)
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 {
info[name] = value
}
*/
if fields := strings.SplitN(scanner.Text(), "=", 2); len(fields) == 2 {
info[fields[0]] = fields[1]
}
}
return info, nil