-
Notifications
You must be signed in to change notification settings - Fork 93
/
product.go
30 lines (25 loc) · 985 Bytes
/
product.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright © 2016 Zlatko Čalušić
//
// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
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"`
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
}
}