mirror of
https://github.com/abice/go-enum.git
synced 2026-10-28 16:46:59 +08:00
88 lines
2.1 KiB
Go
88 lines
2.1 KiB
Go
// Code generated by go-enum DO NOT EDIT.
|
|
// Version: example
|
|
// Revision: example
|
|
// Build Date: example
|
|
// Built By: example
|
|
|
|
//go:build example
|
|
// +build example
|
|
|
|
package example
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
// DiffBaseB3 is a DiffBase of type B3.
|
|
DiffBaseB3 DiffBase = iota + 3
|
|
// DiffBaseB4 is a DiffBase of type B4.
|
|
DiffBaseB4
|
|
// DiffBaseB5 is a DiffBase of type B5.
|
|
DiffBaseB5
|
|
// DiffBaseB6 is a DiffBase of type B6.
|
|
DiffBaseB6
|
|
// DiffBaseB7 is a DiffBase of type B7.
|
|
DiffBaseB7
|
|
// DiffBaseB8 is a DiffBase of type B8.
|
|
DiffBaseB8
|
|
// DiffBaseB9 is a DiffBase of type B9.
|
|
DiffBaseB9
|
|
// DiffBaseB10 is a DiffBase of type B10.
|
|
DiffBaseB10 DiffBase = iota + 4
|
|
// DiffBaseB11 is a DiffBase of type B11.
|
|
DiffBaseB11 DiffBase = iota + 35
|
|
)
|
|
|
|
var ErrInvalidDiffBase = errors.New("not a valid DiffBase")
|
|
|
|
const _DiffBaseName = "b3b4b5b6b7b8b9b10b11"
|
|
|
|
var _DiffBaseMap = map[DiffBase]string{
|
|
DiffBaseB3: _DiffBaseName[0:2],
|
|
DiffBaseB4: _DiffBaseName[2:4],
|
|
DiffBaseB5: _DiffBaseName[4:6],
|
|
DiffBaseB6: _DiffBaseName[6:8],
|
|
DiffBaseB7: _DiffBaseName[8:10],
|
|
DiffBaseB8: _DiffBaseName[10:12],
|
|
DiffBaseB9: _DiffBaseName[12:14],
|
|
DiffBaseB10: _DiffBaseName[14:17],
|
|
DiffBaseB11: _DiffBaseName[17:20],
|
|
}
|
|
|
|
// String implements the Stringer interface.
|
|
func (x DiffBase) String() string {
|
|
if str, ok := _DiffBaseMap[x]; ok {
|
|
return str
|
|
}
|
|
return fmt.Sprintf("DiffBase(%d)", x)
|
|
}
|
|
|
|
// IsValid provides a quick way to determine if the typed value is
|
|
// part of the allowed enumerated values
|
|
func (x DiffBase) IsValid() bool {
|
|
_, ok := _DiffBaseMap[x]
|
|
return ok
|
|
}
|
|
|
|
var _DiffBaseValue = map[string]DiffBase{
|
|
_DiffBaseName[0:2]: DiffBaseB3,
|
|
_DiffBaseName[2:4]: DiffBaseB4,
|
|
_DiffBaseName[4:6]: DiffBaseB5,
|
|
_DiffBaseName[6:8]: DiffBaseB6,
|
|
_DiffBaseName[8:10]: DiffBaseB7,
|
|
_DiffBaseName[10:12]: DiffBaseB8,
|
|
_DiffBaseName[12:14]: DiffBaseB9,
|
|
_DiffBaseName[14:17]: DiffBaseB10,
|
|
_DiffBaseName[17:20]: DiffBaseB11,
|
|
}
|
|
|
|
// ParseDiffBase attempts to convert a string to a DiffBase.
|
|
func ParseDiffBase(name string) (DiffBase, error) {
|
|
if x, ok := _DiffBaseValue[name]; ok {
|
|
return x, nil
|
|
}
|
|
return DiffBase(0), fmt.Errorf("%s is %w", name, ErrInvalidDiffBase)
|
|
}
|