strconvh

package
v0.0.0-...-61d31b1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2018 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Overview

Package strconvh provides functions for conversion between basic types and its string representations.

String representation for numeric use 10-base. Most of functions have suffix in form of [u]int[8,16,32,64] or float{32,64}. This suffix defines inputs and outputs types for number parameters. So it helps avoid a lot of conversions in code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBool

func FormatBool(b bool) string

FormatBool returns "true" or "false" according to the value of b

func FormatComplex128

func FormatComplex128(c complex128) string

FormatComplex128 is a shortcut for FormatComplex128Prec with prec=-1.

func FormatComplex128Prec

func FormatComplex128Prec(c complex128, prec int) string

FormatComplex128Prec returns the string representation of c in form of "(-1.2+3.4i)". The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseComplex128Prec will return c exactly.

func FormatComplex64

func FormatComplex64(c complex64) string

FormatComplex64 is a shortcut for FormatComplex64Prec with prec=-1.

func FormatComplex64Prec

func FormatComplex64Prec(c complex64, prec int) string

FormatComplex64Prec returns the string representation of c in form of "(-1.2+3.4i)". The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseComplex64Prec will return c exactly.

func FormatFloat32

func FormatFloat32(f float32) string

FormatFloat32 is a shortcut for FormatFloat32Prec with prec=-1.

func FormatFloat32Prec

func FormatFloat32Prec(f float32, prec int) string

FormatFloat32Prec returns the string representation of f in the 10-base. The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseFloat32Prec will return f exactly.

func FormatFloat64

func FormatFloat64(f float64) string

FormatFloat64 is a shortcut for FormatFloat64Prec with prec=-1.

func FormatFloat64Prec

func FormatFloat64Prec(f float64, prec int) string

FormatFloat64Prec returns the string representation of f in the 10-base. The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseFloat64Prec will return f exactly.

func FormatInt

func FormatInt(i int) string

FormatInt returns the string representation of i in the 10-base.

func FormatInt16

func FormatInt16(i int16) string

FormatInt16 returns the string representation of i in the 10-base.

func FormatInt32

func FormatInt32(i int32) string

FormatInt32 returns the string representation of i in the 10-base.

func FormatInt64

func FormatInt64(i int64) string

FormatInt64 returns the string representation of i in the 10-base.

func FormatInt8

func FormatInt8(i int8) string

FormatInt8 returns the string representation of i in the 10-base.

func FormatUint

func FormatUint(i uint) string

FormatUint returns the string representation of i in the 10-base.

func FormatUint16

func FormatUint16(i uint16) string

FormatUint16 returns the string representation of i in the 10-base.

func FormatUint32

func FormatUint32(i uint32) string

FormatUint32 returns the string representation of i in the 10-base.

func FormatUint64

func FormatUint64(i uint64) string

FormatUint64 returns the string representation of i in the 10-base.

func FormatUint8

func FormatUint8(i uint8) string

FormatUint8 returns the string representation of i in the 10-base.

func ParseBool

func ParseBool(str string) (bool, error)

ParseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.

func ParseComplex128

func ParseComplex128(s string) (c complex128, err error)

ParseComplex128 converts the string s to a complex128. Valid form are "<float64>","<float64>i","<float64><float64 with sign>i" and optionally can be parenthesized. ParseComplex128 internally uses ParseFloat64 for parsing real and imaginary parts. The errors that ParseComplex128 returns have concrete type *NumError and include err.Num = s.

func ParseComplex64

func ParseComplex64(s string) (c complex64, err error)

ParseComplex64 converts the string s to a complex64. Valid form are "<float32>","<float32>i","<float32><float32 with sign>i" and optionally can be parenthesized. ParseComplex64 internally uses ParseFloat32 for parsing real and imaginary parts. The errors that ParseComplex64 returns have concrete type *NumError and include err.Num = s.

func ParseFloat32

func ParseFloat32(s string) (f float32, err error)

ParseFloat32 interprets a string s in 10-base and returns the corresponding value f (float32) and error.

func ParseFloat64

func ParseFloat64(s string) (float64, error)

ParseFloat64 interprets a string s in 10-base and returns the corresponding value f (float64) and error.

func ParseInt

func ParseInt(stringValue string) (i int, err error)

ParseInt interprets a string s in 10-base and returns the corresponding value i (int) and error.

func ParseInt16

func ParseInt16(stringValue string) (i int16, err error)

ParseInt16 interprets a string s in 10-base and returns the corresponding value i (int16) and error.

func ParseInt32

func ParseInt32(stringValue string) (i int32, err error)

ParseInt32 interprets a string s in 10-base and returns the corresponding value i (int32) and error.

func ParseInt64

func ParseInt64(stringValue string) (int64, error)

ParseInt64 interprets a string s in 10-base and returns the corresponding value i (int64) and error.

func ParseInt8

func ParseInt8(stringValue string) (i int8, err error)

ParseInt8 interprets a string s in 10-base and returns the corresponding value i (int8) and error.

func ParseUint

func ParseUint(stringValue string) (i uint, err error)

ParseUint interprets a string s in 10-base and returns the corresponding value i (uint) and error.

func ParseUint16

func ParseUint16(stringValue string) (i uint16, err error)

ParseUint16 interprets a string s in 10-base and returns the corresponding value i (uint16) and error.

func ParseUint32

func ParseUint32(stringValue string) (i uint32, err error)

ParseUint32 interprets a string s in 10-base and returns the corresponding value i (uint32) and error.

func ParseUint64

func ParseUint64(stringValue string) (uint64, error)

ParseUint64 interprets a string s in 10-base and returns the corresponding value i (uint64) and error.

func ParseUint8

func ParseUint8(stringValue string) (i uint8, err error)

ParseUint8 interprets a string s in 10-base and returns the corresponding value i (uint8) and error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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