From 3b3f85fed70777e3853e8e13727ebef321fc828a Mon Sep 17 00:00:00 2001 From: wudihechao <54797430+wudihechao@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:54:40 +0800 Subject: [PATCH] fix: get the error sn when there is some warning like redheat os get the error sn when there is some warning like redheat os --- config/config.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 54c28acf..457d51ad 100644 --- a/config/config.go +++ b/config/config.go @@ -341,7 +341,16 @@ func GetBiosSn() (string, error) { if err != nil { return "", fmt.Errorf("failed to get bios sn: %v", err) } - sn = strings.TrimSpace(string(out)) + lines := strings.Split(string(out), "\n") + for _, line := range lines { + if strings.HasPrefix(line, "#") { + continue + } + if len(line) > 0 { + sn = strings.TrimSpace(line) + break + } + } default: return "", fmt.Errorf("not support os to get sn") }