Documentation ¶
Index ¶
- Constants
- Variables
- func Clone(from interface{}) (interface{}, error)
- func Coerce(a, b interface{}) (x, y interface{})
- func Compare(a, b interface{}) (int, error)
- func CompareFloat64(x, y float64) int
- func CompareInt64(x, y int64) int
- func CompareInteger(x int64, y uint64) int
- func CompareString(x, y string) int
- func CompareUint64(x, y uint64) int
- func Convert(val interface{}, target *FieldType) (v interface{}, err error)
- func EOFAsNil(err error) error
- func FieldTypeToStr(tp byte, cs string) (r string)
- func InvConv(val interface{}, tp byte) (interface{}, error)
- func InvOp2(x, y interface{}, o opcode.Op) (interface{}, error)
- func IsOrderedType(v interface{}) (y interface{}, r bool, err error)
- func IsTypeBlob(tp byte) bool
- func IsTypeChar(tp byte) bool
- func Overflow(v interface{}, tp byte) error
- func RoundFloat(val float64) float64
- func StrToFloat(str string) (float64, error)
- func StrToInt(str string) (int64, error)
- func StrToUint(str string) (uint64, error)
- func ToBool(value interface{}) (int8, error)
- func ToDecimal(value interface{}) (mysql.Decimal, error)
- func ToFloat64(value interface{}) (float64, error)
- func ToInt64(value interface{}) (int64, error)
- func ToString(value interface{}) (string, error)
- func TruncateFloat(f float64, flen int, decimal int) (float64, error)
- func TypeStr(tp byte) (r string)
- func TypeToStr(tp byte, binary bool) string
- func UndOp(x interface{}, o opcode.Op) (interface{}, error)
- type FieldType
Constants ¶
const (
UnspecifiedLength int = -1
)
UnspecifiedLength is unspecified length.
Variables ¶
var Collators = map[bool]func(a, b []interface{}) int{/* contains filtered or unexported fields */}
Collators maps a boolean value to a collated function.
Functions ¶
func Clone ¶
func Clone(from interface{}) (interface{}, error)
Clone copies a interface to another interface. It does a deep copy.
func Coerce ¶
func Coerce(a, b interface{}) (x, y interface{})
Coerce changes type. If a or b is Decimal, changes the both to Decimal. If a or b is Float, changes the both to Float.
func Compare ¶
Compare returns an integer comparing the interface a to b. a > b -> 1 a = b -> 0 a < b -> -1
func CompareFloat64 ¶
CompareFloat64 returns an integer comparing the float64 x to y.
func CompareInt64 ¶
CompareInt64 returns an integer comparing the int64 x to y.
func CompareInteger ¶
CompareInteger returns an integer comparing the int64 x to the uint64 y.
func CompareString ¶
CompareString returns an integer comparing the string x to y.
func CompareUint64 ¶
CompareUint64 returns an integer comparing the uint64 x to y.
func FieldTypeToStr ¶
FieldTypeToStr converts a field to a string. It is used for converting Text to Blob, or converting Char to Binary. Args:
tp: type enum cs: charset
func IsOrderedType ¶
IsOrderedType returns a boolean whether the type of y can be used by order by.
func IsTypeBlob ¶
IsTypeBlob returns a boolean indicating whether the tp is a blob type.
func IsTypeChar ¶
IsTypeChar returns a boolean indicating whether the tp is the char type like a string type or a varchar type.
func RoundFloat ¶
RoundFloat rounds float val to the nearest integer value with float64 format, like GNU rint function. RoundFloat uses default rounding mode, see http://www.gnu.org/software/libc/manual/html_node/Rounding.html so we will choose the even number if the result is midway between two representable value. e.g, 1.5 -> 2, 2.5 -> 2.
func StrToFloat ¶
StrToFloat converts a string to a float64 in best effort.
func StrToInt ¶
StrToInt converts a string to an integer in best effort. TODO: handle overflow and add unittest.
func StrToUint ¶
StrToUint converts a string to an unsigned integer in best effort. TODO: handle overflow and add unittest.
func TruncateFloat ¶
TruncateFloat tries to truncate f. If the result exceeds the max/min float that flen/decimal allowed, returns the max/min float allowed.
Types ¶
type FieldType ¶
FieldType records field type information.
func NewFieldType ¶
NewFieldType returns a FieldType, with a type and other information about field type.