conver

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2018 License: MIT Imports: 3 Imported by: 20

README

conver GoDoc Build Status

Golang Type Reflect And Conver
package main

import (
	"fmt"

	"github.com/miaolz123/conver"
)

func main() {
	val := "1 234.567\t\n"
	fmt.Println(conver.Float64Must(val)) // output: 1234.567
	fmt.Println(conver.IntMust(val))     // output: 1235
	val = "ok"
	fmt.Println(conver.BoolMust(val))           // output: true
	fmt.Println(conver.Float64Must(val, 666.6)) // output: 666.6
	fmt.Println(conver.IntMust(val, 6666))      // output: 666
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(val interface{}) (bool, error)

Bool : Conver "val" to a Bool

func BoolMust

func BoolMust(val interface{}, def ...bool) bool

BoolMust : Must Conver "val" to a Bool

func Bytes

func Bytes(val interface{}) ([]byte, error)

Bytes : Conver "val" to []byte

func BytesMust

func BytesMust(val interface{}, def ...[]byte) []byte

BytesMust : Must Conver "val" to []byte

func Float32

func Float32(val interface{}) (float32, error)

Float32 : Conver "val" to a Float32

func Float32Must

func Float32Must(val interface{}, def ...float32) float32

Float32Must : Must Conver "val" to Float32

func Float64

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

Float64 : Conver "val" to a Float64

func Float64Must

func Float64Must(val interface{}, def ...float64) float64

Float64Must : Must Conver "val" to Float64

func Int

func Int(val interface{}) (int, error)

Int : Conver "val" to a rounded Int

func Int32

func Int32(val interface{}) (int32, error)

Int32 : Conver "val" to a rounded Int32

func Int32Must

func Int32Must(val interface{}, def ...int32) int32

Int32Must : Must Conver "val" to a rounded Int32

func Int64

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

Int64 : Conver "val" to a rounded Int64

func Int64Must

func Int64Must(val interface{}, def ...int64) int64

Int64Must : Must Conver "val" to a rounded Int64

func IntMust

func IntMust(val interface{}, def ...int) int

IntMust : Must Conver "val" to a rounded Int

func String

func String(val interface{}) (string, error)

String : Conver "val" to a String

func StringMust

func StringMust(val interface{}, def ...string) string

StringMust : Must Conver "val" to a String

Types

This section is empty.

Jump to

Keyboard shortcuts

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