number

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package number provides some utility for int and float

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustParseFloat32

func MustParseFloat32(s string) float32

MustParseFloat32 parse string and return float64 value. it panics if an invalid string is passed.

func MustParseFloat64

func MustParseFloat64(s string) float64

MustParseFloat64 parse string and return float64 value. it panics if an invalid string is passed.

func MustParseInt

func MustParseInt(s string) int

MustParseInt parse string and return int value. it panics if an invalid string is passed.

func MustParseInt64

func MustParseInt64(s string) int64

MustParseInt64 parse string and return int64 value. it panics if an invalid string is passed.

func ParseFloat32Or

func ParseFloat32Or(s string, or float32) float32

ParseFloat32Or parse string and return float64 value. The invalid string returns `or` value.

func ParseFloat64Or

func ParseFloat64Or(s string, or float64) float64

ParseFloat64Or parse string and return float64 value. The invalid string returns `or` value.

func ParseInt64Or

func ParseInt64Or(s string, or int64) int64

ParseInt64Or parse string and return int64 value. The invalid string returns `or` value.

func ParseIntOr

func ParseIntOr(s string, or int) int

ParseIntOr parse string and return int value. The invalid string returns `or` value.

Example
fmt.Println(ParseIntOr("20", 1))
fmt.Println(ParseIntOr("20a", 1))
fmt.Println(ParseIntOr("a", 1))
Output:

20
1
1

Types

This section is empty.

Jump to

Keyboard shortcuts

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