-
Notifications
You must be signed in to change notification settings - Fork 13
/
bitness_enum.go
85 lines (72 loc) · 2.13 KB
/
bitness_enum.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Code generated by go-enum DO NOT EDIT.
// Version: 0.5.3
// Revision: 8e2c93debfc66888870b2dfd86e70c79a70c920f
// Build Date: 2022-11-09T16:39:46Z
// Built By: goreleaser
package arch
import (
"fmt"
"strings"
)
const (
// BitnessInvalid is a Bitness of type Invalid.
BitnessInvalid Bitness = iota
// Bitness32Bit is a Bitness of type 32Bit.
Bitness32Bit Bitness = iota + 31
// Bitness64Bit is a Bitness of type 64Bit.
Bitness64Bit Bitness = iota + 62
)
var ErrInvalidBitness = fmt.Errorf("not a valid Bitness, try [%s]", strings.Join(_BitnessNames, ", "))
const _BitnessName = "invalid32Bit64Bit"
var _BitnessNames = []string{
_BitnessName[0:7],
_BitnessName[7:12],
_BitnessName[12:17],
}
// BitnessNames returns a list of possible string values of Bitness.
func BitnessNames() []string {
tmp := make([]string, len(_BitnessNames))
copy(tmp, _BitnessNames)
return tmp
}
var _BitnessMap = map[Bitness]string{
BitnessInvalid: _BitnessName[0:7],
Bitness32Bit: _BitnessName[7:12],
Bitness64Bit: _BitnessName[12:17],
}
// String implements the Stringer interface.
func (x Bitness) String() string {
if str, ok := _BitnessMap[x]; ok {
return str
}
return fmt.Sprintf("Bitness(%d)", x)
}
var _BitnessValue = map[string]Bitness{
_BitnessName[0:7]: BitnessInvalid,
strings.ToLower(_BitnessName[0:7]): BitnessInvalid,
_BitnessName[7:12]: Bitness32Bit,
strings.ToLower(_BitnessName[7:12]): Bitness32Bit,
_BitnessName[12:17]: Bitness64Bit,
strings.ToLower(_BitnessName[12:17]): Bitness64Bit,
}
// ParseBitness attempts to convert a string to a Bitness.
func ParseBitness(name string) (Bitness, error) {
if x, ok := _BitnessValue[name]; ok {
return x, nil
}
return Bitness(0), fmt.Errorf("%s is %w", name, ErrInvalidBitness)
}
// MarshalText implements the text marshaller method.
func (x Bitness) MarshalText() ([]byte, error) {
return []byte(x.String()), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *Bitness) UnmarshalText(text []byte) error {
name := string(text)
tmp, err := ParseBitness(name)
if err != nil {
return err
}
*x = tmp
return nil
}