From a9ae8c1fa73c9a661a95cabf63fb887f6e012263 Mon Sep 17 00:00:00 2001 From: wudihechao Date: Mon, 20 May 2024 13:40:31 +0800 Subject: [PATCH] fix: filter the case when sn is empty --- config/config.go | 4 ---- config/hostname.go | 6 ++---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index 882b2380..736e16d8 100644 --- a/config/config.go +++ b/config/config.go @@ -208,10 +208,6 @@ func (c *ConfigType) GetHostIP() string { } func (c *ConfigType) GetHostSN() string { ret := HostInfo.GetSN() - if ret == "" { - return c.GetHostname() - } - return ret } func GetEnv(key string) string { diff --git a/config/hostname.go b/config/hostname.go index f9a151c9..bc5635c5 100644 --- a/config/hostname.go +++ b/config/hostname.go @@ -83,10 +83,8 @@ func InitHostInfo() error { ip = fmt.Sprint(nip) } var sn string - sn, err = GetBiosSn() - if err != nil { - return err - } + // allow sn empty + sn, _ = GetBiosSn() HostInfo = &HostInfoCache{ name: hostname, ip: fmt.Sprint(ip),