mirror of
https://github.com/abice/go-enum.git
synced 2026-10-29 00:56:10 +08:00
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Code generated by go-enum DO NOT EDIT.
|
|
// Version: example
|
|
// Revision: example
|
|
// Build Date: example
|
|
// Built By: example
|
|
|
|
package example
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
// AcmeIncProductAnvil is a Product of type Anvil.
|
|
AcmeIncProductAnvil Product = iota
|
|
// AcmeIncProductDynamite is a Product of type Dynamite.
|
|
AcmeIncProductDynamite
|
|
// AcmeIncProductGlue is a Product of type Glue.
|
|
AcmeIncProductGlue
|
|
)
|
|
|
|
const _ProductName = "AnvilDynamiteGlue"
|
|
|
|
var _ProductMap = map[Product]string{
|
|
AcmeIncProductAnvil: _ProductName[0:5],
|
|
AcmeIncProductDynamite: _ProductName[5:13],
|
|
AcmeIncProductGlue: _ProductName[13:17],
|
|
}
|
|
|
|
// String implements the Stringer interface.
|
|
func (x Product) String() string {
|
|
if str, ok := _ProductMap[x]; ok {
|
|
return str
|
|
}
|
|
return fmt.Sprintf("Product(%d)", x)
|
|
}
|
|
|
|
var _ProductValue = map[string]Product{
|
|
_ProductName[0:5]: AcmeIncProductAnvil,
|
|
_ProductName[5:13]: AcmeIncProductDynamite,
|
|
_ProductName[13:17]: AcmeIncProductGlue,
|
|
}
|
|
|
|
// ParseProduct attempts to convert a string to a Product.
|
|
func ParseProduct(name string) (Product, error) {
|
|
if x, ok := _ProductValue[name]; ok {
|
|
return x, nil
|
|
}
|
|
return Product(0), fmt.Errorf("%s is not a valid Product", name)
|
|
}
|