forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
architecture.go
38 lines (31 loc) · 1016 Bytes
/
architecture.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
//
// 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"
// Architecture describes the overall hardware architecture. It can be either
// Symmetric Multi-Processor (SMP) or Non-Uniform Memory Access (NUMA)
type Architecture int
const (
// SMP is a Symmetric Multi-Processor system
ARCHITECTURE_SMP Architecture = iota
// NUMA is a Non-Uniform Memory Access system
ARCHITECTURE_NUMA
)
var (
architectureString = map[Architecture]string{
ARCHITECTURE_SMP: "SMP",
ARCHITECTURE_NUMA: "NUMA",
}
)
func (a Architecture) String() string {
return architectureString[a]
}
// 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 (a Architecture) MarshalJSON() ([]byte, error) {
return []byte("\"" + strings.ToLower(a.String()) + "\""), nil
}