Files
go-enum/_example/custom_prefix_enum.go
Alex Bice 2bf3f089be move examples folder (#112)
* Remove the need for the examples repo to be tested
2022-06-17 13:32:51 -07:00

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)
}