xcast

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package xcast provides utilities for lossless type conversions.

Example
package main

import (
	"fmt"

	"github.com/ctx42/convert/pkg/xcast"
)

func main() {
	// Successful cast.
	ui8, err := xcast.IntToUint8(42)
	fmt.Printf("xcast.IntToUint8 output: %[1]T(%[1]d) error: %v\n", ui8, err)

	// Value too big for uint8.
	ui8, err = xcast.IntToUint8(420)
	fmt.Printf("xcast.IntToUint8 output: %[1]T(%[1]d) error: %v\n", ui8, err)

	// Unsafe cast.
	f32, err := xcast.IntToFloat32(xcast.Float32SafeIntMax + 1)
	fmt.Printf("xcast.IntToUint8 output: %[1]T(%[1]g) error: %v\n", f32, err)

}
Output:
xcast.IntToUint8 output: uint8(42) error: <nil>
xcast.IntToUint8 output: uint8(0) error: int value out of range for uint8
xcast.IntToUint8 output: float32(0) error: int value out of safe range for float32

Index

Examples

Constants

View Source
const (
	// Float32SafeIntMin represents the smallest int32 exactly representable by
	// the float32 type.
	Float32SafeIntMin = -(1 << 24) + 1

	// Float32SafeIntMax represents the biggest int32 exactly representable by
	// the float32 type.
	Float32SafeIntMax = 1<<24 - 1
)

Safe integer boundaries for exact round-trip float32 to int32 conversions. The float32 can exactly represent all integers in the range [-2^24+1,2^24-1]. Outside this range, some integers cannot be represented precisely, and conversion to / from integers will lose information or round incorrectly.

View Source
const (
	// Float64SafeIntMin represents the smallest int exactly representable by
	// the float64 type.
	Float64SafeIntMin = -(1 << 53) + 1

	// Float64SafeIntMax represents the biggest int exactly representable by
	// the float64 type.
	Float64SafeIntMax = 1<<53 - 1
)

Safe integer boundaries for round-trip float64 to int64 conversions. The float64 can exactly represent all integers in the range [-2^53+1,2^53-1]. Outside this range, some integers cannot be represented precisely, and conversion to / from integers will lose information or round incorrectly.

Variables

View Source
var (
	// ErrInvRange used when the input value isn't within a valid range of the
	// destination type.
	ErrInvRange = errors.New("value out of range")

	// ErrInvSafeRange used when input is within the valid range for conversion,
	// but conversion may lose precision.
	ErrInvSafeRange = errors.New("value out of safe range")

	// ErrUnkType used when conversion for a type is not defined.
	ErrUnkType = errors.New("unknown type")

	// ErrInvType used when a type is not valid in a given conversion context.
	ErrInvType = errors.New("invalid type")

	// ErrInvValue used when a value is not valid in a given conversion context.
	ErrInvValue = errors.New("invalid value")

	// ErrInvFormat used when a value's format is not valid in a given
	// conversion context.
	ErrInvFormat = errors.New("invalid format")

	// ErrUndConv used when conversion is undefined for given types.
	ErrUndConv = errors.New("conversion undefined")

	// ErrUnsupported represents explicitly not supported conversion.
	ErrUnsupported = errors.New("not supported cast")
)

Sentinel errors.

Functions

func BoolToBool added in v0.3.0

func BoolToBool(value bool) (bool, error)

BoolToBool is a nop function converting a given boolean value to boolean.

func ByteToByte

func ByteToByte(value byte) (byte, error)

ByteToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToFloat32

func ByteToFloat32(value byte) (float32, error)

ByteToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToFloat64

func ByteToFloat64(value byte) (float64, error)

ByteToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToInt

func ByteToInt(value byte) (int, error)

ByteToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToInt8

func ByteToInt8(value byte) (int8, error)

ByteToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToInt16

func ByteToInt16(value byte) (int16, error)

ByteToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToInt32

func ByteToInt32(value byte) (int32, error)

ByteToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToInt64

func ByteToInt64(value byte) (int64, error)

ByteToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToRune

func ByteToRune(value byte) (rune, error)

ByteToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToUint

func ByteToUint(value byte) (uint, error)

ByteToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToUint8

func ByteToUint8(value byte) (uint8, error)

ByteToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToUint16

func ByteToUint16(value byte) (uint16, error)

ByteToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToUint32

func ByteToUint32(value byte) (uint32, error)

ByteToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToUint64

func ByteToUint64(value byte) (uint64, error)

ByteToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func ByteToUintptr

func ByteToUintptr(value byte) (uintptr, error)

ByteToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToByte

func Float32ToByte(value float32) (byte, error)

Float32ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToFloat32

func Float32ToFloat32(value float32) (float32, error)

Float32ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToFloat64

func Float32ToFloat64(value float32) (float64, error)

Float32ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToInt

func Float32ToInt(value float32) (int, error)

Float32ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToInt8

func Float32ToInt8(value float32) (int8, error)

Float32ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToInt16

func Float32ToInt16(value float32) (int16, error)

Float32ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToInt32

func Float32ToInt32(value float32) (int32, error)

Float32ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToInt64

func Float32ToInt64(value float32) (int64, error)

Float32ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToRune

func Float32ToRune(value float32) (rune, error)

Float32ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToUint

func Float32ToUint(value float32) (uint, error)

Float32ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToUint8

func Float32ToUint8(value float32) (uint8, error)

Float32ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToUint16

func Float32ToUint16(value float32) (uint16, error)

Float32ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToUint32

func Float32ToUint32(value float32) (uint32, error)

Float32ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToUint64

func Float32ToUint64(value float32) (uint64, error)

Float32ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float32ToUintptr

func Float32ToUintptr(value float32) (uintptr, error)

Float32ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToByte

func Float64ToByte(value float64) (byte, error)

Float64ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToFloat32

func Float64ToFloat32(value float64) (float32, error)

Float64ToFloat32 converts a given numeric value to float32. But this is one of those cases when it's easy to lose precision; therefore, only the casts of whole numbers are allowed in range from Float32SafeIntMin to Float32SafeIntMax.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToFloat64

func Float64ToFloat64(value float64) (float64, error)

Float64ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToInt

func Float64ToInt(value float64) (int, error)

Float64ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToInt8

func Float64ToInt8(value float64) (int8, error)

Float64ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToInt16

func Float64ToInt16(value float64) (int16, error)

Float64ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToInt32

func Float64ToInt32(value float64) (int32, error)

Float64ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToInt64

func Float64ToInt64(value float64) (int64, error)

Float64ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToRune

func Float64ToRune(value float64) (rune, error)

Float64ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToUint

func Float64ToUint(value float64) (uint, error)

Float64ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToUint8

func Float64ToUint8(value float64) (uint8, error)

Float64ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToUint16

func Float64ToUint16(value float64) (uint16, error)

Float64ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToUint32

func Float64ToUint32(value float64) (uint32, error)

Float64ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToUint64

func Float64ToUint64(value float64) (uint64, error)

Float64ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Float64ToUintptr

func Float64ToUintptr(value float64) (uintptr, error)

Float64ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToByte

func Int8ToByte(value int8) (byte, error)

Int8ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToFloat32

func Int8ToFloat32(value int8) (float32, error)

Int8ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToFloat64

func Int8ToFloat64(value int8) (float64, error)

Int8ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToInt

func Int8ToInt(value int8) (int, error)

Int8ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToInt8

func Int8ToInt8(value int8) (int8, error)

Int8ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToInt16

func Int8ToInt16(value int8) (int16, error)

Int8ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToInt32

func Int8ToInt32(value int8) (int32, error)

Int8ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToInt64

func Int8ToInt64(value int8) (int64, error)

Int8ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToRune

func Int8ToRune(value int8) (rune, error)

Int8ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToUint

func Int8ToUint(value int8) (uint, error)

Int8ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToUint8

func Int8ToUint8(value int8) (uint8, error)

Int8ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToUint16

func Int8ToUint16(value int8) (uint16, error)

Int8ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToUint32

func Int8ToUint32(value int8) (uint32, error)

Int8ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToUint64

func Int8ToUint64(value int8) (uint64, error)

Int8ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int8ToUintptr

func Int8ToUintptr(value int8) (uintptr, error)

Int8ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToByte

func Int16ToByte(value int16) (byte, error)

Int16ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToFloat32

func Int16ToFloat32(value int16) (float32, error)

Int16ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToFloat64

func Int16ToFloat64(value int16) (float64, error)

Int16ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToInt

func Int16ToInt(value int16) (int, error)

Int16ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToInt8

func Int16ToInt8(value int16) (int8, error)

Int16ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToInt16

func Int16ToInt16(value int16) (int16, error)

Int16ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToInt32

func Int16ToInt32(value int16) (int32, error)

Int16ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToInt64

func Int16ToInt64(value int16) (int64, error)

Int16ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToRune

func Int16ToRune(value int16) (rune, error)

Int16ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToUint

func Int16ToUint(value int16) (uint, error)

Int16ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToUint8

func Int16ToUint8(value int16) (uint8, error)

Int16ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToUint16

func Int16ToUint16(value int16) (uint16, error)

Int16ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToUint32

func Int16ToUint32(value int16) (uint32, error)

Int16ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToUint64

func Int16ToUint64(value int16) (uint64, error)

Int16ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int16ToUintptr

func Int16ToUintptr(value int16) (uintptr, error)

Int16ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToByte

func Int32ToByte(value int32) (byte, error)

Int32ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToFloat32

func Int32ToFloat32(value int32) (float32, error)

Int32ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToFloat64

func Int32ToFloat64(value int32) (float64, error)

Int32ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToInt

func Int32ToInt(value int32) (int, error)

Int32ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToInt8

func Int32ToInt8(value int32) (int8, error)

Int32ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToInt16

func Int32ToInt16(value int32) (int16, error)

Int32ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToInt32

func Int32ToInt32(value int32) (int32, error)

Int32ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToInt64

func Int32ToInt64(value int32) (int64, error)

Int32ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToRune

func Int32ToRune(value int32) (rune, error)

Int32ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToUint

func Int32ToUint(value int32) (uint, error)

Int32ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToUint8

func Int32ToUint8(value int32) (uint8, error)

Int32ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToUint16

func Int32ToUint16(value int32) (uint16, error)

Int32ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToUint32

func Int32ToUint32(value int32) (uint32, error)

Int32ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToUint64

func Int32ToUint64(value int32) (uint64, error)

Int32ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int32ToUintptr

func Int32ToUintptr(value int32) (uintptr, error)

Int32ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToByte

func Int64ToByte(value int64) (byte, error)

Int64ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToFloat32

func Int64ToFloat32(value int64) (float32, error)

Int64ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToFloat64

func Int64ToFloat64(value int64) (float64, error)

Int64ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToInt

func Int64ToInt(value int64) (int, error)

Int64ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToInt8

func Int64ToInt8(value int64) (int8, error)

Int64ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToInt16

func Int64ToInt16(value int64) (int16, error)

Int64ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToInt32

func Int64ToInt32(value int64) (int32, error)

Int64ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToInt64

func Int64ToInt64(value int64) (int64, error)

Int64ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToRune

func Int64ToRune(value int64) (rune, error)

Int64ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToUint

func Int64ToUint(value int64) (uint, error)

Int64ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToUint8

func Int64ToUint8(value int64) (uint8, error)

Int64ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToUint16

func Int64ToUint16(value int64) (uint16, error)

Int64ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToUint32

func Int64ToUint32(value int64) (uint32, error)

Int64ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToUint64

func Int64ToUint64(value int64) (uint64, error)

Int64ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Int64ToUintptr

func Int64ToUintptr(value int64) (uintptr, error)

Int64ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToByte

func IntToByte(value int) (byte, error)

IntToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToFloat32

func IntToFloat32(value int) (float32, error)

IntToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToFloat64

func IntToFloat64(value int) (float64, error)

IntToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToInt

func IntToInt(value int) (int, error)

IntToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToInt8

func IntToInt8(value int) (int8, error)

IntToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToInt16

func IntToInt16(value int) (int16, error)

IntToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToInt32

func IntToInt32(value int) (int32, error)

IntToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToInt64

func IntToInt64(value int) (int64, error)

IntToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToRune

func IntToRune(value int) (rune, error)

IntToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToUint

func IntToUint(value int) (uint, error)

IntToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToUint8

func IntToUint8(value int) (uint8, error)

IntToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToUint16

func IntToUint16(value int) (uint16, error)

IntToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToUint32

func IntToUint32(value int) (uint32, error)

IntToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToUint64

func IntToUint64(value int) (uint64, error)

IntToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func IntToUintptr

func IntToUintptr(value int) (uintptr, error)

IntToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToByte

func RuneToByte(value rune) (byte, error)

RuneToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToFloat32

func RuneToFloat32(value rune) (float32, error)

RuneToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToFloat64

func RuneToFloat64(value rune) (float64, error)

RuneToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToInt

func RuneToInt(value rune) (int, error)

RuneToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToInt8

func RuneToInt8(value rune) (int8, error)

RuneToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToInt16

func RuneToInt16(value rune) (int16, error)

RuneToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToInt32

func RuneToInt32(value rune) (int32, error)

RuneToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToInt64

func RuneToInt64(value rune) (int64, error)

RuneToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToRune

func RuneToRune(value rune) (rune, error)

RuneToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToUint

func RuneToUint(value rune) (uint, error)

RuneToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToUint8

func RuneToUint8(value rune) (uint8, error)

RuneToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToUint16

func RuneToUint16(value rune) (uint16, error)

RuneToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToUint32

func RuneToUint32(value rune) (uint32, error)

RuneToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToUint64

func RuneToUint64(value rune) (uint64, error)

RuneToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func RuneToUintptr

func RuneToUintptr(value rune) (uintptr, error)

RuneToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func StringToDuration added in v0.3.0

func StringToDuration(value string) (time.Duration, error)

StringToDuration returns a parser function that converts a string to a time.Duration. If parsing fails, the returned function yields a zero time.Duration and an error describing the issue.

func StringToString added in v0.3.0

func StringToString(value string) (string, error)

StringToString is a nop function converting a given string value to string.

func StringToTime added in v0.2.0

func StringToTime(format string) func(value string) (time.Time, error)

StringToTime returns a parser function that converts a string to a time.Time according to the specified layout. The layout must follow time.Parse rules. If parsing fails, the returned function yields a zero time.Time and an error describing the issue.

func SupportedTypes

func SupportedTypes() []reflect.Type

SupportedTypes returns a slice of reflect.Type instances containing all types for which the package provides built-in converters. Any pair of types from this list can be converted in either direction.

func Uint8ToByte

func Uint8ToByte(value uint8) (byte, error)

Uint8ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToFloat32

func Uint8ToFloat32(value uint8) (float32, error)

Uint8ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToFloat64

func Uint8ToFloat64(value uint8) (float64, error)

Uint8ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToInt

func Uint8ToInt(value uint8) (int, error)

Uint8ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToInt8

func Uint8ToInt8(value uint8) (int8, error)

Uint8ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToInt16

func Uint8ToInt16(value uint8) (int16, error)

Uint8ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToInt32

func Uint8ToInt32(value uint8) (int32, error)

Uint8ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToInt64

func Uint8ToInt64(value uint8) (int64, error)

Uint8ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToRune

func Uint8ToRune(value uint8) (rune, error)

Uint8ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToUint

func Uint8ToUint(value uint8) (uint, error)

Uint8ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToUint8

func Uint8ToUint8(value uint8) (uint8, error)

Uint8ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToUint16

func Uint8ToUint16(value uint8) (uint16, error)

Uint8ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToUint32

func Uint8ToUint32(value uint8) (uint32, error)

Uint8ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToUint64

func Uint8ToUint64(value uint8) (uint64, error)

Uint8ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint8ToUintptr

func Uint8ToUintptr(value uint8) (uintptr, error)

Uint8ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToByte

func Uint16ToByte(value uint16) (byte, error)

Uint16ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToFloat32

func Uint16ToFloat32(value uint16) (float32, error)

Uint16ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToFloat64

func Uint16ToFloat64(value uint16) (float64, error)

Uint16ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToInt

func Uint16ToInt(value uint16) (int, error)

Uint16ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToInt8

func Uint16ToInt8(value uint16) (int8, error)

Uint16ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToInt16

func Uint16ToInt16(value uint16) (int16, error)

Uint16ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToInt32

func Uint16ToInt32(value uint16) (int32, error)

Uint16ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToInt64

func Uint16ToInt64(value uint16) (int64, error)

Uint16ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToRune

func Uint16ToRune(value uint16) (rune, error)

Uint16ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToUint

func Uint16ToUint(value uint16) (uint, error)

Uint16ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToUint8

func Uint16ToUint8(value uint16) (uint8, error)

Uint16ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToUint16

func Uint16ToUint16(value uint16) (uint16, error)

Uint16ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToUint32

func Uint16ToUint32(value uint16) (uint32, error)

Uint16ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToUint64

func Uint16ToUint64(value uint16) (uint64, error)

Uint16ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint16ToUintptr

func Uint16ToUintptr(value uint16) (uintptr, error)

Uint16ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToByte

func Uint32ToByte(value uint32) (byte, error)

Uint32ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToFloat32

func Uint32ToFloat32(value uint32) (float32, error)

Uint32ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToFloat64

func Uint32ToFloat64(value uint32) (float64, error)

Uint32ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToInt

func Uint32ToInt(value uint32) (int, error)

Uint32ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToInt8

func Uint32ToInt8(value uint32) (int8, error)

Uint32ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToInt16

func Uint32ToInt16(value uint32) (int16, error)

Uint32ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToInt32

func Uint32ToInt32(value uint32) (int32, error)

Uint32ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToInt64

func Uint32ToInt64(value uint32) (int64, error)

Uint32ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToRune

func Uint32ToRune(value uint32) (rune, error)

Uint32ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToUint

func Uint32ToUint(value uint32) (uint, error)

Uint32ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToUint8

func Uint32ToUint8(value uint32) (uint8, error)

Uint32ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToUint16

func Uint32ToUint16(value uint32) (uint16, error)

Uint32ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToUint32

func Uint32ToUint32(value uint32) (uint32, error)

Uint32ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToUint64

func Uint32ToUint64(value uint32) (uint64, error)

Uint32ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint32ToUintptr

func Uint32ToUintptr(value uint32) (uintptr, error)

Uint32ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToByte

func Uint64ToByte(value uint64) (byte, error)

Uint64ToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToFloat32

func Uint64ToFloat32(value uint64) (float32, error)

Uint64ToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToFloat64

func Uint64ToFloat64(value uint64) (float64, error)

Uint64ToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToInt

func Uint64ToInt(value uint64) (int, error)

Uint64ToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToInt8

func Uint64ToInt8(value uint64) (int8, error)

Uint64ToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToInt16

func Uint64ToInt16(value uint64) (int16, error)

Uint64ToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToInt32

func Uint64ToInt32(value uint64) (int32, error)

Uint64ToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToInt64

func Uint64ToInt64(value uint64) (int64, error)

Uint64ToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToRune

func Uint64ToRune(value uint64) (rune, error)

Uint64ToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToUint

func Uint64ToUint(value uint64) (uint, error)

Uint64ToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToUint8

func Uint64ToUint8(value uint64) (uint8, error)

Uint64ToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToUint16

func Uint64ToUint16(value uint64) (uint16, error)

Uint64ToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToUint32

func Uint64ToUint32(value uint64) (uint32, error)

Uint64ToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToUint64

func Uint64ToUint64(value uint64) (uint64, error)

Uint64ToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func Uint64ToUintptr

func Uint64ToUintptr(value uint64) (uintptr, error)

Uint64ToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToByte

func UintToByte(value uint) (byte, error)

UintToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToFloat32

func UintToFloat32(value uint) (float32, error)

UintToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToFloat64

func UintToFloat64(value uint) (float64, error)

UintToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToInt

func UintToInt(value uint) (int, error)

UintToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToInt8

func UintToInt8(value uint) (int8, error)

UintToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToInt16

func UintToInt16(value uint) (int16, error)

UintToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToInt32

func UintToInt32(value uint) (int32, error)

UintToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToInt64

func UintToInt64(value uint) (int64, error)

UintToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToRune

func UintToRune(value uint) (rune, error)

UintToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToUint

func UintToUint(value uint) (uint, error)

UintToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToUint8

func UintToUint8(value uint) (uint8, error)

UintToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToUint16

func UintToUint16(value uint) (uint16, error)

UintToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToUint32

func UintToUint32(value uint) (uint32, error)

UintToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToUint64

func UintToUint64(value uint) (uint64, error)

UintToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintToUintptr

func UintToUintptr(value uint) (uintptr, error)

UintToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToByte

func UintptrToByte(value uintptr) (byte, error)

UintptrToByte converts a given numeric value to byte.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToFloat32

func UintptrToFloat32(value uintptr) (float32, error)

UintptrToFloat32 converts a given numeric value to float32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToFloat64

func UintptrToFloat64(value uintptr) (float64, error)

UintptrToFloat64 converts a given numeric value to float64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToInt

func UintptrToInt(value uintptr) (int, error)

UintptrToInt converts a given numeric value to int.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToInt8

func UintptrToInt8(value uintptr) (int8, error)

UintptrToInt8 converts a given numeric value to int8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToInt16

func UintptrToInt16(value uintptr) (int16, error)

UintptrToInt16 converts a given numeric value to int16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToInt32

func UintptrToInt32(value uintptr) (int32, error)

UintptrToInt32 converts a given numeric value to int32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToInt64

func UintptrToInt64(value uintptr) (int64, error)

UintptrToInt64 converts a given numeric value to int64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToRune

func UintptrToRune(value uintptr) (rune, error)

UintptrToRune converts a given numeric value to rune.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToUint

func UintptrToUint(value uintptr) (uint, error)

UintptrToUint converts a given numeric value to uint.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToUint8

func UintptrToUint8(value uintptr) (uint8, error)

UintptrToUint8 converts a given numeric value to uint8.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToUint16

func UintptrToUint16(value uintptr) (uint16, error)

UintptrToUint16 converts a given numeric value to uint16.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToUint32

func UintptrToUint32(value uintptr) (uint32, error)

UintptrToUint32 converts a given numeric value to uint32.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToUint64

func UintptrToUint64(value uintptr) (uint64, error)

UintptrToUint64 converts a given numeric value to uint64.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

func UintptrToUintptr

func UintptrToUintptr(value uintptr) (uintptr, error)

UintptrToUintptr converts a given numeric value to uintptr.

It succeeds only if the numeric value can be exactly preserved without loss or truncation. Otherwise, it returns an error.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL