forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbus_type.go
42 lines (35 loc) · 913 Bytes
/
bus_type.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
31
32
33
34
35
36
37
38
39
40
41
42
//
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
//
package ghw
import "strings"
type BusType int
const (
BUS_TYPE_UNKNOWN BusType = iota
BUS_TYPE_IDE
BUS_TYPE_PCI
BUS_TYPE_SCSI
BUS_TYPE_NVME
BUS_TYPE_VIRTIO
)
var (
busTypeString = map[BusType]string{
BUS_TYPE_UNKNOWN: "Unknown",
BUS_TYPE_IDE: "IDE",
BUS_TYPE_PCI: "PCI",
BUS_TYPE_SCSI: "SCSI",
BUS_TYPE_NVME: "NVMe",
BUS_TYPE_VIRTIO: "Virtio",
}
)
func (bt BusType) String() string {
return busTypeString[bt]
}
// NOTE(jaypipes): since serialized output is as "official" as we're going to
// get, let's lowercase the string output when serializing, in order to
// "normalize" the expected serialized output
func (bt BusType) MarshalJSON() ([]byte, error) {
return []byte("\"" + strings.ToLower(bt.String()) + "\""), nil
}