Skip to content

Commit

Permalink
Include product SKU and UUID in Product information
Browse files Browse the repository at this point in the history
  • Loading branch information
PeaceRebel authored and zcalusic committed Oct 20, 2023
1 parent 4ca1cf8 commit 4eac1cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/zcalusic/sysinfo

go 1.20

require github.com/google/uuid v1.3.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
18 changes: 14 additions & 4 deletions product.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@

package sysinfo

import "github.com/google/uuid"

// Product information.
type Product struct {
Name string `json:"name,omitempty"`
Vendor string `json:"vendor,omitempty"`
Version string `json:"version,omitempty"`
Serial string `json:"serial,omitempty"`
Name string `json:"name,omitempty"`
Vendor string `json:"vendor,omitempty"`
Version string `json:"version,omitempty"`
Serial string `json:"serial,omitempty"`
UUID uuid.UUID `json:"uuid,omitempty"`
SKU string `json:"sku,omitempty"`
}

func (si *SysInfo) getProductInfo() {
si.Product.Name = slurpFile("/sys/class/dmi/id/product_name")
si.Product.Vendor = slurpFile("/sys/class/dmi/id/sys_vendor")
si.Product.Version = slurpFile("/sys/class/dmi/id/product_version")
si.Product.Serial = slurpFile("/sys/class/dmi/id/product_serial")
si.Product.SKU = slurpFile("/sys/class/dmi/id/product_sku")

uid, err := uuid.Parse(slurpFile("/sys/class/dmi/id/product_uuid"))
if err == nil {
si.Product.UUID = uid
}
}

0 comments on commit 4eac1cf

Please sign in to comment.