mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
Disable warnings from ghw library when retrieving chassis information. These warnings are undesirable but recoverable errors that emit unnecessary log messages. Using WithDisableWarnings() suppresses them while maintaining functionality.
21 lines
582 B
Go
21 lines
582 B
Go
//go:build !darwin
|
|
|
|
package system
|
|
|
|
import "github.com/jaypipes/ghw"
|
|
|
|
// GetChassisInfo retrieves hardware information including machine model type and vendor from the system profiler.
|
|
func GetChassisInfo() (*ChassisInfo, error) {
|
|
// Disable warnings from ghw, since these are undesirable but recoverable errors.
|
|
// With warnings enabled, ghw will emit unnecessary log messages.
|
|
chassis, err := ghw.Chassis(ghw.WithDisableWarnings())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
info := &ChassisInfo{
|
|
Type: chassis.TypeDescription,
|
|
Vendor: chassis.Vendor,
|
|
}
|
|
return info, nil
|
|
}
|