Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter the case when sn is empty #940

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 3 additions & 7 deletions config/hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -114,9 +112,7 @@ func (c *HostInfoCache) update() {
HostInfo.SetIP(fmt.Sprint(ip))
}
sn, err := GetBiosSn()
if err != nil {
log.Println("E! failed to get sn:", err)
} else {
if err == nil {
HostInfo.SetSN(sn)
}
}
Expand Down
Loading