Skip to content

Commit

Permalink
If Lenovo return SystemFamily instead since its more human readable…
Browse files Browse the repository at this point in the history
… (e.g. `ThinkPad P1 Gen 6`) rather than `21FWS4...`

PiperOrigin-RevId: 622276025
  • Loading branch information
mjoliver authored and copybara-github committed Apr 5, 2024
1 parent 0fca011 commit e2cb03c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions go/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build windows
// +build windows

// Package device supports querying information about the local device.
Expand All @@ -21,6 +22,7 @@ import (
"errors"
"fmt"
"os"
"strings"

"github.com/StackExchange/wmi"
)
Expand Down Expand Up @@ -72,10 +74,12 @@ func ChassisType() (Type, error) {

// Win32_ComputerSystem models the WMI object of the same name.
type Win32_ComputerSystem struct {
DNSHostName string
Domain string
DomainRole int
Model string
DNSHostName string
Domain string
DomainRole int
Model string
SystemFamily string
Manufacturer string
}

func sysInfo() (*Win32_ComputerSystem, error) {
Expand Down Expand Up @@ -127,6 +131,9 @@ func Model() (string, error) {
if err != nil {
return "unknown", err
}
if strings.ToLower(si.Manufacturer) == "lenovo" {
return si.SystemFamily, nil
}
return si.Model, nil
}

Expand Down

0 comments on commit e2cb03c

Please sign in to comment.