coerce

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package coerce provides c-style coercion for numeric types and strings, with additional guarantees for preservation of information.

Index

Constants

View Source
const (
	ErrOverflowInt64       errorlib.ErrorString = "overflow of int64"
	ErrImpreciseConversion errorlib.ErrorString = "data loss on conversion to float64"
	ErrWrongType           errorlib.ErrorString = "could not coerce type"
)

Variables

This section is empty.

Functions

func AllowImpreciseConversion

func AllowImpreciseConversion(b bool)

func AllowOverflow

func AllowOverflow(b bool)

func Float64

func Float64(v interface{}) (float64, error)

Float64 converts a numeric type to a float64, if possible. Note for very large integers, this may lose information!

func Int64

func Int64(v interface{}) (int64, error)

Int64 converts an integer type to an int64, if possible. Note that for very large unsigned ints, this may give an incorrect result!

func String

func String(v interface{}) (string, bool)

String converts strings, []bytes, and []runes to strings

func WarnOnImpreciseConversion

func WarnOnImpreciseConversion(b bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

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