Documentation
¶
Index ¶
- Constants
- Variables
- type Base
- type Country
- func (v Country) Int() int
- func (v Country) IsValid() bool
- func (v Country) JSON() string
- func (v Country) MarshalJSON() ([]byte, error)
- func (v Country) MarshalText() ([]byte, error)
- func (v Country) Ordinal() int
- func (v *Country) Parse(in string) error
- func (v *Country) Scan(value interface{}) error
- func (v Country) String() string
- func (v Country) Text() string
- func (v *Country) UnmarshalJSON(text []byte) error
- func (v *Country) UnmarshalText(bs []byte) error
- func (v Country) Value() (driver.Value, error)
- type Day
- type GreekAlphabet
- func (v GreekAlphabet) Int() int
- func (v GreekAlphabet) IsValid() bool
- func (v GreekAlphabet) MarshalText() ([]byte, error)
- func (v GreekAlphabet) Ordinal() int
- func (v *GreekAlphabet) Parse(in string) error
- func (v *GreekAlphabet) Scan(value interface{}) error
- func (v GreekAlphabet) String() string
- func (v GreekAlphabet) Text() string
- func (v *GreekAlphabet) UnmarshalText(bs []byte) error
- func (v GreekAlphabet) Value() (driver.Value, error)
- type Method
- func (v Method) Int() int
- func (v Method) IsValid() bool
- func (v Method) JSON() string
- func (v Method) MarshalJSON() ([]byte, error)
- func (v Method) Ordinal() int
- func (v *Method) Parse(in string) error
- func (v *Method) Scan(value interface{}) error
- func (v Method) String() string
- func (v *Method) UnmarshalJSON(text []byte) error
- func (v Method) Value() (driver.Value, error)
- type Month
- type Pet
- type SalesChannel
- func (v SalesChannel) Int() int
- func (v SalesChannel) IsValid() bool
- func (v SalesChannel) JSON() string
- func (v SalesChannel) MarshalJSON() ([]byte, error)
- func (v SalesChannel) Ordinal() int
- func (v *SalesChannel) Parse(in string) error
- func (v *SalesChannel) Scan(value interface{}) error
- func (v SalesChannel) String() string
- func (v *SalesChannel) UnmarshalJSON(text []byte) error
- func (v SalesChannel) Value() (driver.Value, error)
Constants ¶
const IgnoreThisItem, AndThis = 741, "quack"
preamble const declarations are ignored by the enumeration tool
const (
// One is ignored by the enumeration tool too
One = 1
)
Variables ¶
var AllBaseEnums = enum.FloatEnums{ A, C, G, T, }
AllBaseEnums lists all 4 values in order.
AllBases lists all 4 values in order.
var AllCountries = []Country{}/* 247 elements not displayed */
AllCountries lists all 247 values in order.
AllDays lists all 7 values in order.
var AllGreekAlphabets = []GreekAlphabet{ Αλφα, Βήτα, Γάμμα, Δέλτα, Εψιλον, Ζήτα, Ητα, Θήτα, Ιώτα, Κάππα, Λάμβδα, Μυ, Νυ, Ξι, Ομικρον, Πι, Ρώ, Σίγμα, Ταυ, Υψιλον, Φι, Χι, Ψι, Ωμέγα, }
AllGreekAlphabets lists all 24 values in order.
AllMethodEnums lists all 6 values in order.
AllMethods lists all 6 values in order.
var AllMonths = []Month{ January, February, March, April, May, June, July, August, September, October, November, December, }
AllMonths lists all 12 values in order.
var AllPets = []Pet{ MyCat, MyDog, MyMouse, MyElephant, MyKoala_Bear, }
AllPets lists all 5 values in order.
var AllSalesChannelEnums = enum.IntEnums{ OnlineSales, InstoreSales, TelephoneSales, }
AllSalesChannelEnums lists all 3 values in order.
var AllSalesChannels = []SalesChannel{ OnlineSales, InstoreSales, TelephoneSales, }
AllSalesChannels lists all 3 values in order.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base float32
Base example demonstrates using floating point values instead of integers. These are float32 but could be float64; the only other restriction is that no two values can be the same number.
const A Base = 331.2
Nucleotide Molecular Weights, g/mol
const C Base = 307.2
const G Base = 347.2
const T Base = 322.2
func AsBase ¶
AsBase parses a string to find the corresponding Base, accepting either one of the string values or a number. It wraps Parse.
func BaseOf ¶
BaseOf returns a Base based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Base is returned.
func MustParseBase ¶
MustParseBase is similar to AsBase except that it panics on error.
func (Base) Float ¶
Float returns the float64 value. It serves to facilitate polymorphism (see enum.FloatEnum).
func (Base) Ordinal ¶
Ordinal returns the ordinal number of a Base. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
type Country ¶
type Country int
Country example shows use of the '-plural' option to set the name of plural collections. Because of '-ic', the parser ignores case. Because of '-unsnake', the parser treats underscores and spaces alike.
When generating JSON & SQL values, the 2-letter ISO-3166 country codes are used. This is determined by the `all` tags in comments. The 2-letter codes are also accepted when parsing.
The '-alias' option also allows 3-letter ISO-3166 tags to be parsed as their corresponding country using the map iso3166_3LetterCodes.
const ( Afghanistan Country = iota // all:"af" Åland_Islands // all:"ax" Albania // all:"al" Algeria // all:"dz" American_Samoa // all:"as" Andorra // all:"ad" Angola // all:"ao" Anguilla // all:"ai" Antarctica // all:"aq" Antigua_and_Barbuda // all:"ag" Argentina // all:"ar" Armenia // all:"am" Aruba // all:"aw" Australia // all:"au" Austria // all:"at" Azerbaijan // all:"az" Bahamas // all:"bs" Bahrain // all:"bh" Bangladesh // all:"bd" Barbados // all:"bb" Belarus // all:"by" Belgium // all:"be" Belize // all:"bz" Benin // all:"bj" Bermuda // all:"bm" Bhutan // all:"bt" Bolivia // all:"bo" Bosnia_and_Herzegovina // all:"ba" Botswana // all:"bw" Bouvet_Island // all:"bv" Brazil // all:"br" British_Virgin_Islands // all:"vg" British_Indian_Ocean_Territory // all:"io" Brunei_Darussalam // all:"dn" Bulgaria // all:"bg" Burkina_Faso // all:"bf" Burundi // all:"bi" Cambodia // all:"kh" Cameroon // all:"cm" Canada // all:"ca" Cape_Verde // all:"cv" Cayman_Islands // all:"ky" Central_African_Republic // all:"cf" Chad // all:"td" Chile // all:"cl" China // all:"cn" Hong_Kong // all:"hk" -- Special Administrative Region of China Macao // all:"mo" -- Special Administrative Region of China Christmas_Island // all:"cx" Cocos_Islands // all:"cc" -- Cocos (Keeling) Islands Colombia // all:"co" Comoros // all:"km" Congo_Brazzaville // all:"cg" -- Congo (Brazzaville) Congo_DRC // all:"cd" -- Democratic Republic of the Congo Cook_Islands // all:"ck" Costa_Rica // all:"cr" Côte_dIvoire // all:"ci" -- Côte_d’Ivoire Croatia // all:"hr" Cuba // all:"cu" Cyprus // all:"cy" Czechia // all:"cz" Denmark // all:"dk" Djibouti // all:"dj" Dominica // all:"dm" Dominican_Republic // all:"do" Ecuador // all:"ec" Egypt // all:"eg" El_Salvador // all:"sv" Equatorial_Guinea // all:"gq" Eritrea // all:"er" Estonia // all:"ee" Ethiopia // all:"et" Falkland_Islands // all:"fk" -- Falkland Islands (Malvinas) Faroe_Islands // all:"fo" Fiji // all:"fj" Finland // all:"fi" France // all:"fr" French_Guiana // all:"gf" French_Polynesia // all:"pf" French_Southern_Territories // all:"tf" Gabon // all:"ga" Gambia // all:"gm" Georgia // all:"ge" Germany // all:"de" Ghana // all:"gh" Gibraltar // all:"gi" Greece // all:"gr" Greenland // all:"gl" Grenada // all:"gd" Guadeloupe // all:"gp" Guam // all:"gu" Guatemala // all:"gt" Guernsey // all:"gg" Guinea // all:"gn" Guinea_Bissau // all:"gw" Guyana // all:"gy" Haiti // all:"ht" Heard_Island_and_Mcdonald_Islands // all:"hm" Holy_See // all:"va" -- Vatican City State Honduras // all:"hn" Hungary // all:"hu" Iceland // all:"is" India // all:"in" Indonesia // all:"id" Iran // all:"ir" -- Islamic Republic of Iran Iraq // all:"iq" Ireland // all:"ie" Isle_of_Man // all:"im" Israel // all:"il" Italy // all:"it" Jamaica // all:"jm" Japan // all:"jp" Jersey // all:"je" Jordan // all:"jo" Kazakhstan // all:"kz" Kenya // all:"ke" Kiribati // all:"ki" Democratic_Peoples_Republic_of_Korea // all:"kp" -- Democratic People’s Republic of Korea South_Korea // all:"kr" -- Republic of Korea Kuwait // all:"kw" Kyrgyzstan // all:"kg" Lao_PDR // all:"la" Latvia // all:"lv" Lebanon // all:"lb" Lesotho // all:"ls" Liberia // all:"lr" Libya // all:"ly" Liechtenstein // all:"li" Lithuania // all:"lt" Luxembourg // all:"lu" North_Macedonia // all:"mk" -- Republic of North_Macedonia Madagascar // all:"mg" Malawi // all:"mw" Malaysia // all:"my" Maldives // all:"mv" Mali // all:"ml" Malta // all:"mt" Marshall_Islands // all:"mh" Martinique // all:"mq" Mauritania // all:"mr" Mauritius // all:"mu" Mayotte // all:"yt" Mexico // all:"mx" Micronesia // all:"fm" -- Federated States of Micronesia Moldova // all:"md" Monaco // all:"mc" Mongolia // all:"mn" Montenegro // all:"me" Montserrat // all:"ms" Morocco // all:"ma" Mozambique // all:"mz" Myanmar // all:"mm" Namibia // all:"na" Nauru // all:"nr" Nepal // all:"np" Netherlands // all:"nl", Netherlands_Antilles // all:"an" -- obsolete New_Caledonia // all:"nc", New_Zealand // all:"nz", Nicaragua // all:"ni", Niger // all:"ne", Nigeria // all:"ng", Niue // all:"nu", Norfolk_Island // all:"nf", Northern_Mariana_Islands // all:"mp", Norway // all:"no", Oman // all:"om", Pakistan // all:"pk", Palau // all:"pw", Palestinian_Territory // all:"ps", -- Palestinian Territory, Occupied Panama // all:"pa", Papua_New_Guinea // all:"pg", Paraguay // all:"py", Peru // all:"pe", Philippines // all:"ph", Pitcairn // all:"pn", Poland // all:"pl", Portugal // all:"pt", Puerto_Rico // all:"pr", Qatar // all:"qa", Réunion // all:"re", Romania // all:"ro", Russian_Federation // all:"ru", Rwanda // all:"rw", Saint_Barthélemy // all:"bl", Saint_Helena // all:"sh", Saint_Kitts_and_Nevis // all:"kn", Saint_Lucia // all:"lc" Saint_Martin // all:"mf" -- Saint-Martin (French part) Saint_Pierre_and_Miquelon // all:"pm" Saint_Vincent_and_Grenadines // all:"vc" Samoa // all:"ws" San_Marino // all:"sm" Sao_Tome_and_Principe // all:"st" Saudi_Arabia // all:"sa" Senegal // all:"sn" Serbia // all:"rs" Seychelles // all:"sc" Sierra_Leone // all:"sl" Singapore // all:"sg" Slovakia // all:"sk" Slovenia // all:"si" Solomon_Islands // all:"sb" Somalia // all:"so" South_Africa // all:"za" South_Georgia_and_the_South_Sandwich_Islands // all:"gs" South_Sudan // all:"ss" Spain // all:"es" Sri_Lanka // all:"lk" Sudan // all:"sd" Suriname // all:"sr" Svalbard_and_Jan_Mayen_Islands // all:"sj" Swaziland // all:"sz" -- Eswatini Sweden // all:"se" Switzerland // all:"ch" Syria // all:"sy" -- Syrian Arab Republic Taiwan // all:"tw" -- Taiwan, Republic of China Tajikistan // all:"tj" Tanzania // all:"tz" -- United Republic of Tanzania Thailand // all:"th" Timor_Leste // all:"tl" Togo // all:"tg" Tokelau // all:"tk" Tonga // all:"to" Trinidad_and_Tobago // all:"tt" Tunisia // all:"tn" Türkiye // all:"tr" Turkmenistan // all:"tm" Turks_and_Caicos_Islands // all:"tc" Tuvalu // all:"tv" Uganda // all:"ug" Ukraine // all:"ua" United_Arab_Emirates // all:"ae" United_Kingdom // all:"gb" United_States_of_America // all:"us" United_States_Minor_Outlying_Islands // all:"um" Uruguay // all:"uy" Uzbekistan // all:"uz" Vanuatu // all:"vu" Venezuela // all:"ve" -- Bolivarian Republic of Venezuela Viet_Nam // all:"vn" Virgin_Islands // all:"vi" Wallis_and_Futuna_Islands // all:"wf" Western_Sahara // all:"eh" Yemen // all:"ye" Zambia // all:"zm" Zimbabwe // all:"zw" )
func AsCountry ¶
AsCountry parses a string to find the corresponding Country, accepting either one of the string values or a number. It wraps Parse. The input case does not matter.
func CountryOf ¶
CountryOf returns a Country based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Country is returned.
func MustParseCountry ¶
MustParseCountry is similar to AsCountry except that it panics on error. The input case does not matter.
func (Country) Int ¶
Int returns the int value, which is not necessarily the same as the ordinal. This facilitates polymorphism (see enum.IntEnum).
func (Country) JSON ¶
JSON returns an approximation to the representation used for transmission via JSON. However, strings are not quoted.
func (Country) MarshalJSON ¶
MarshalJSON converts values to bytes suitable for transmission via JSON. The representation is chosen according to 'json' struct tags.
func (Country) MarshalText ¶
MarshalText converts values to bytes suitable for transmission via XML, JSON etc.
func (Country) Ordinal ¶
Ordinal returns the ordinal number of a Country. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
func (*Country) Parse ¶
Parse parses a string to find the corresponding Country, accepting one of the string values or a number. It is used by AsCountry. The input case does not matter.
Usage Example
v := new(Country) err := v.Parse(s) ... etc
func (*Country) Scan ¶
Scan parses some value, which can be a number, a string or []byte. It implements sql.Scanner, https://golang.org/pkg/database/sql/#Scanner
func (Country) String ¶
String returns the literal string representation of a Country, which is the same as the const identifier but without prefix or suffix.
func (*Country) UnmarshalJSON ¶
UnmarshalJSON converts transmitted JSON values to ordinary values. It allows both ordinals and strings to represent the values.
func (*Country) UnmarshalText ¶
UnmarshalText converts transmitted values to ordinary values.
type Day ¶
type Day uint
Day simple example also shows that more than one 'const' block can be used provided that the integer values are all distinct.
const ( Sunday Day Monday Tuesday Wednesday )
It is allowable to break the constant blocks (although it's a bit unnecessary here). However, the numeric values *must* all be distinct, otherwise the generated enum will not compile.
func AsDay ¶
AsDay parses a string to find the corresponding Day, accepting either one of the string values or a number. It wraps Parse.
func DayOf ¶
DayOf returns a Day based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Day is returned.
func MustParseDay ¶
MustParseDay is similar to AsDay except that it panics on error.
func (Day) Int ¶
Int returns the int value, which is not necessarily the same as the ordinal. This facilitates polymorphism (see enum.IntEnum).
func (Day) Ordinal ¶
Ordinal returns the ordinal number of a Day. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
type GreekAlphabet ¶
type GreekAlphabet int
GreekAlphabet example shows non-ASCII characters in use. There is also a cross-mapping table specified via the '-using' option. So the parser recognises inputs from both sets of strings.
See also https://unicode.org/charts/PDF/U0370.pdf https://en.wikipedia.org/wiki/Greek_alphabet
const ( Αλφα GreekAlphabet = iota + 1 // text:"alpha" sql:"\u0391" = Α Βήτα // text:"beta" sql:"\u0392" Γάμμα // text:"gamma" sql:"\u0393" Δέλτα // text:"delta" sql:"\u0394" Εψιλον // text:"epsilon" sql:"\u0395" Ζήτα // text:"zeta" sql:"\u0396" Ητα // text:"eta" sql:"\u0397" Θήτα // text:"theta" sql:"\u0398" Ιώτα // text:"iota" sql:"\u0399" Κάππα // text:"kappa" sql:"\u039A" Λάμβδα // text:"lambda" sql:"\u039B" Μυ // text:"mu" sql:"\u039C" Νυ // text:"nu" sql:"\u039D" Ξι // text:"xi" sql:"\u039E" Ομικρον // text:"omicron" sql:"\u039F" Πι // text:"pi" sql:"\u03A0" Ρώ // text:"rho" sql:"\u03A1" Σίγμα // text:"sigma" sql:"\u03A3" Ταυ // text:"tau" sql:"\u03A4" Υψιλον // text:"upsilon" sql:"\u03A5" Φι // text:"phi" sql:"\u03A6" Χι // text:"chi" sql:"\u03A7" Ψι // text:"psi" sql:"\u03A8" Ωμέγα // text:"omega" sql:"\u03A9" )
func AsGreekAlphabet ¶
func AsGreekAlphabet(s string) (GreekAlphabet, error)
AsGreekAlphabet parses a string to find the corresponding GreekAlphabet, accepting either one of the string values or a number. It wraps Parse.
func GreekAlphabetOf ¶
func GreekAlphabetOf(v int) GreekAlphabet
GreekAlphabetOf returns a GreekAlphabet based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid GreekAlphabet is returned.
func MustParseGreekAlphabet ¶
func MustParseGreekAlphabet(s string) GreekAlphabet
MustParseGreekAlphabet is similar to AsGreekAlphabet except that it panics on error.
func (GreekAlphabet) Int ¶
func (v GreekAlphabet) Int() int
Int returns the int value, which is not necessarily the same as the ordinal. This facilitates polymorphism (see enum.IntEnum).
func (GreekAlphabet) IsValid ¶
func (v GreekAlphabet) IsValid() bool
IsValid determines whether a GreekAlphabet is one of the defined constants.
func (GreekAlphabet) MarshalText ¶
func (v GreekAlphabet) MarshalText() ([]byte, error)
MarshalText converts values to bytes suitable for transmission via XML, JSON etc.
func (GreekAlphabet) Ordinal ¶
func (v GreekAlphabet) Ordinal() int
Ordinal returns the ordinal number of a GreekAlphabet. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
func (*GreekAlphabet) Parse ¶
func (v *GreekAlphabet) Parse(in string) error
Parse parses a string to find the corresponding GreekAlphabet, accepting one of the string values or a number. It is used by AsGreekAlphabet.
Usage Example
v := new(GreekAlphabet) err := v.Parse(s) ... etc
func (*GreekAlphabet) Scan ¶
func (v *GreekAlphabet) Scan(value interface{}) error
Scan parses some value, which can be a number, a string or []byte. It implements sql.Scanner, https://golang.org/pkg/database/sql/#Scanner
func (GreekAlphabet) String ¶
func (v GreekAlphabet) String() string
String returns the literal string representation of a GreekAlphabet, which is the same as the const identifier but without prefix or suffix.
func (GreekAlphabet) Text ¶
func (v GreekAlphabet) Text() string
Text returns the representation used for transmission via XML, JSON etc.
func (*GreekAlphabet) UnmarshalText ¶
func (v *GreekAlphabet) UnmarshalText(bs []byte) error
UnmarshalText converts transmitted values to ordinary values.
func (GreekAlphabet) Value ¶
func (v GreekAlphabet) Value() (driver.Value, error)
Value converts the GreekAlphabet to a string. The representation is chosen according to 'sql' struct tags. It implements driver.Valuer, https://golang.org/pkg/database/sql/driver/#Valuer
type Method ¶
type Method uint
Method example has json tags that control the JSON representations. So the parser recognises inputs from thes and the identifiers too. The '-ic' option means the parser ignores the case of its inputs.
See also SalesChannel.
func AsMethod ¶
AsMethod parses a string to find the corresponding Method, accepting either one of the string values or a number. It wraps Parse. The input case does not matter.
func MethodOf ¶
MethodOf returns a Method based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Method is returned.
func MustParseMethod ¶
MustParseMethod is similar to AsMethod except that it panics on error. The input case does not matter.
func (Method) Int ¶
Int returns the int value, which is not necessarily the same as the ordinal. This facilitates polymorphism (see enum.IntEnum).
func (Method) JSON ¶
JSON returns an approximation to the representation used for transmission via JSON. However, strings are not quoted.
func (Method) MarshalJSON ¶
MarshalJSON converts values to bytes suitable for transmission via JSON. The representation is chosen according to 'json' struct tags.
func (Method) Ordinal ¶
Ordinal returns the ordinal number of a Method. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
func (*Method) Parse ¶
Parse parses a string to find the corresponding Method, accepting one of the string values or a number. It is used by AsMethod. The input case does not matter.
Usage Example
v := new(Method) err := v.Parse(s) ... etc
func (*Method) Scan ¶
Scan parses some value, which can be a number, a string or []byte. It implements sql.Scanner, https://golang.org/pkg/database/sql/#Scanner
func (Method) String ¶
String returns the literal string representation of a Method, which is the same as the const identifier but without prefix or suffix.
func (*Method) UnmarshalJSON ¶
UnmarshalJSON converts transmitted JSON values to ordinary values. It allows both ordinals and strings to represent the values.
type Month ¶
type Month uint
Month example shows that several comma-separated enumeration constants can be on each line, and they can have explicit values. The '-ic' option means the parser ignores the case of its inputs.
func AsMonth ¶
AsMonth parses a string to find the corresponding Month, accepting either one of the string values or a number. The input representation is determined by monthMarshalTextRep. It wraps Parse. The input case does not matter.
func MonthOf ¶
MonthOf returns a Month based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Month is returned.
func MustParseMonth ¶
MustParseMonth is similar to AsMonth except that it panics on error. The input case does not matter.
func (Month) Int ¶
Int returns the int value, which is not necessarily the same as the ordinal. This facilitates polymorphism (see enum.IntEnum).
func (Month) MarshalText ¶
MarshalText converts values to bytes suitable for transmission via XML, JSON etc.
func (Month) Ordinal ¶
Ordinal returns the ordinal number of a Month. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
func (*Month) Parse ¶
Parse parses a string to find the corresponding Month, accepting one of the string values or a number. The input representation is determined by Identifier. It is used by AsMonth. The input case does not matter.
Usage Example
v := new(Month) err := v.Parse(s) ... etc
func (Month) String ¶
String returns the literal string representation of a Month, which is the same as the const identifier but without prefix or suffix.
func (*Month) UnmarshalText ¶
UnmarshalText converts transmitted values to ordinary values.
type Pet ¶
type Pet uint16
Pet example has a cross-mapping table specified via the 'text' tags. So the parser recognises inputs from both sets of strings. Also:
The '-lc' option means the parser expects lowercase inputs and the String method gives lowercase values.
The -prefix option means each identifer, MyCat etc, is stored in the enumeration as just "cat" without the "My" prefix.
Because of '-unsnake', underscores are replaced with spaces so "MyKoala_Bear" is treated as "koala bear".
Because of the '-lenient' option, the parser will allow numbers outside the valid range 0 to 4.
const ( MyCat Pet = iota // text:"Felis Catus" MyDog // text:"Canis Lupus" MyMouse // text:"Mus Musculus" MyElephant // text:"Loxodonta Africana" MyKoala_Bear // text:"Phascolarctos Cinereus" )
These all have prefix "My", which is stripped from the String representation.
func AsPet ¶
AsPet parses a string to find the corresponding Pet, accepting either one of the string values or a number. It wraps Parse.
func MustParsePet ¶
MustParsePet is similar to AsPet except that it panics on error.
func PetOf ¶
PetOf returns a Pet based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Pet is returned.
func (Pet) Int ¶
Int returns the int value, which is not necessarily the same as the ordinal. This facilitates polymorphism (see enum.IntEnum).
func (Pet) MarshalText ¶
MarshalText converts values to bytes suitable for transmission via XML, JSON etc.
func (Pet) Ordinal ¶
Ordinal returns the ordinal number of a Pet. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
func (*Pet) Parse ¶
Parse parses a string to find the corresponding Pet, accepting one of the string values or a number. It is used by AsPet.
Usage Example
v := new(Pet) err := v.Parse(s) ... etc
func (Pet) String ¶
String returns the literal string representation of a Pet, which is the same as the const identifier but without prefix or suffix.
func (*Pet) UnmarshalText ¶
UnmarshalText converts transmitted values to ordinary values.
type SalesChannel ¶
type SalesChannel int
SalesChannel example demonstrates the removing of a suffix string from the identifiers when their string equivalent is accessed.
The `json` tags in comments control values used for JSON marshalling. The `sql` tags in comments control values used for SQL storage.
const ( OnlineSales SalesChannel = 3 // json:"webshop" sql:"o" -- String() is "online" InstoreSales SalesChannel = 5 // json:"store" sql:"s" -- String() is "instore" TelephoneSales SalesChannel = 7 // json:"phone" sql:"t" -- String() is "telephone" )
func AsSalesChannel ¶
func AsSalesChannel(s string) (SalesChannel, error)
AsSalesChannel parses a string to find the corresponding SalesChannel, accepting either one of the string values or a number. It wraps Parse.
func MustParseSalesChannel ¶
func MustParseSalesChannel(s string) SalesChannel
MustParseSalesChannel is similar to AsSalesChannel except that it panics on error.
func SalesChannelOf ¶
func SalesChannelOf(v int) SalesChannel
SalesChannelOf returns a SalesChannel based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid SalesChannel is returned.
func (SalesChannel) Int ¶
func (v SalesChannel) Int() int
Int returns the int value, which is not necessarily the same as the ordinal. This facilitates polymorphism (see enum.IntEnum).
func (SalesChannel) IsValid ¶
func (v SalesChannel) IsValid() bool
IsValid determines whether a SalesChannel is one of the defined constants.
func (SalesChannel) JSON ¶
func (v SalesChannel) JSON() string
JSON returns an approximation to the representation used for transmission via JSON. However, strings are not quoted.
func (SalesChannel) MarshalJSON ¶
func (v SalesChannel) MarshalJSON() ([]byte, error)
MarshalJSON converts values to bytes suitable for transmission via JSON. The representation is chosen according to 'json' struct tags.
func (SalesChannel) Ordinal ¶
func (v SalesChannel) Ordinal() int
Ordinal returns the ordinal number of a SalesChannel. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.
func (*SalesChannel) Parse ¶
func (v *SalesChannel) Parse(in string) error
Parse parses a string to find the corresponding SalesChannel, accepting one of the string values or a number. It is used by AsSalesChannel.
Usage Example
v := new(SalesChannel) err := v.Parse(s) ... etc
func (*SalesChannel) Scan ¶
func (v *SalesChannel) Scan(value interface{}) error
Scan parses some value, which can be a number, a string or []byte. It implements sql.Scanner, https://golang.org/pkg/database/sql/#Scanner
func (SalesChannel) String ¶
func (v SalesChannel) String() string
String returns the literal string representation of a SalesChannel, which is the same as the const identifier but without prefix or suffix.
func (*SalesChannel) UnmarshalJSON ¶
func (v *SalesChannel) UnmarshalJSON(text []byte) error
UnmarshalJSON converts transmitted JSON values to ordinary values. It allows both ordinals and strings to represent the values.
func (SalesChannel) Value ¶
func (v SalesChannel) Value() (driver.Value, error)
Value converts the SalesChannel to a string. The representation is chosen according to 'sql' struct tags. It implements driver.Valuer, https://golang.org/pkg/database/sql/driver/#Valuer