From 75ceda8bb241649e546934c88842397cef79908f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Tue, 14 Jun 2022 20:02:10 +0200 Subject: [PATCH] collector/diskstats: Don't use functions from Go 1.18 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- collector/diskstats_linux.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/collector/diskstats_linux.go b/collector/diskstats_linux.go index 663f7902..893684e5 100644 --- a/collector/diskstats_linux.go +++ b/collector/diskstats_linux.go @@ -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