Documentation ¶
Overview ¶
Package intstr implements a custom type for handling values that can be either a string or an int32
Index ¶
Constants ¶
const NullValue = IntOrString("")
NullValue is an empty IntOrString value
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntOrString ¶
type IntOrString string
IntOrString holds a value that can be either a string or a int
func FromInt32 ¶
func FromInt32(value int32) IntOrString
FromInt32 return a IntOrString from a int32
func FromString ¶
func FromString(value string) IntOrString
FromString return a IntOrString from a string
func (IntOrString) AsPercentage ¶
func (value IntOrString) AsPercentage() (int32, bool)
AsPercentage return the value of a string transformed in a percentage and reports if this conversion was possible. '10%' return 10 and true, while "10", "foo" return 0 and false.
func (IntOrString) Int32 ¶
func (value IntOrString) Int32() int32
Int32 returns the value of the IntOrString as an int32. If the current value is not an string, 0 is returned
func (IntOrString) IsInt ¶
func (value IntOrString) IsInt() bool
IsInt returns true if the value is an integer
func (IntOrString) IsNull ¶
func (value IntOrString) IsNull() bool
IsNull checks if the IntOrString value is the Int NullValue
func (IntOrString) IsZero ¶
func (value IntOrString) IsZero() bool
IsZero checks if the IntOrString value is an integer 0
func (IntOrString) Str ¶
func (value IntOrString) Str() string
Str returns the value of the IntOrString as a string.
func (IntOrString) Type ¶
func (value IntOrString) Type() ValueType
Type returns the ValueType of a IntOrString value