t

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 4 Imported by: 25

README

t

golang type extension. Conversion of Basic Types.
(golang基本数据类型的相互转换)

catalog index

usage

1. standard type convertion (标准类型转换)

package main

import (
	"fmt"
	"github.com/gohouse/t"
)

func main()  {
	var a = "8.8"
	fmt.Println(t.ParseString(a))
	fmt.Println(t.ParseFloat64(a))
	fmt.Println(t.ParseInt64(a))
	fmt.Println(t.ParseInt(a))
	fmt.Println(t.ParseUint64(a))
	fmt.Println(t.ParseUint(a))
	fmt.Println(t.ParseBool(a))
}

result

8.8
8.8
8
8
8
8
true

2. type bind convertion (类型定义转换)

package main

import (
	"fmt"
	"github.com/gohouse/t"
)

func main()  {
    var b t.T
    b = t.New("2.3")

    fmt.Println(b.String())
    fmt.Println(b.Float64())
    fmt.Println(b.Float32())
    fmt.Println(b.Int64())
    fmt.Println(b.Int())
    fmt.Println(b.Int32())
    fmt.Println(b.Int16())
    fmt.Println(b.Int8())
    fmt.Println(b.Uint64())
    fmt.Println(b.Uint())
    fmt.Println(b.Uint32())
    fmt.Println(b.Uint16())
    fmt.Println(b.Uint8())
    fmt.Println(b.Bool())
}

result

2.3
2.3
2.3
2
2
2
2
2
2
2
2
2
2
true

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBool

func ParseBool(o interface{}) bool

func ParseFloat32

func ParseFloat32(o interface{}) float32

func ParseFloat64

func ParseFloat64(o interface{}) (res float64)

func ParseInt

func ParseInt(o interface{}) int

func ParseInt16

func ParseInt16(o interface{}) (res int16)

func ParseInt32

func ParseInt32(o interface{}) (res int32)

func ParseInt64

func ParseInt64(o interface{}) (res int64)

func ParseInt8

func ParseInt8(o interface{}) (res int8)

func ParseString

func ParseString(o interface{}) string

func ParseUint

func ParseUint(o interface{}) uint

func ParseUint16

func ParseUint16(o interface{}) uint16

func ParseUint32

func ParseUint32(o interface{}) uint32

func ParseUint64

func ParseUint64(o interface{}) uint64

func ParseUint8

func ParseUint8(o interface{}) uint8

Types

type Map added in v0.0.4

type Map map[T]T

type MapInt64 added in v0.0.4

type MapInt64 map[int64]T

type MapInterface added in v0.0.4

type MapInterface map[interface{}]T

type MapString added in v0.0.4

type MapString map[string]T

type MapStringInterface added in v0.0.5

type MapStringInterface map[string]interface{}

type Slice added in v0.0.4

type Slice []T

type SliceInt64 added in v0.0.4

type SliceInt64 []int64

type SliceInterface added in v0.0.4

type SliceInterface []interface{}

type SliceString added in v0.0.4

type SliceString []string

type T

type T interface {
	Interface() interface{}
	String() string
	Float64() float64
	Float32() float32
	Int64() int64
	Int() int
	Int32() int32
	Int16() int16
	Int8() int8
	Uint64() uint64
	Uint() uint
	Uint32() uint32
	Uint16() uint16
	Uint8() uint8
	Bool() bool
	Slice() Slice
	SliceInterface() []interface{}
	SliceMapStringInterface() []map[string]interface{}
	SliceString() []string
	SliceInt64() []int64
	Map() Map
	MapInterface() MapInterface
	MapString() MapString
	MapInt64() MapInt64
	MapStringInterface() map[string]interface{}
}

type Type

type Type struct {
	// contains filtered or unexported fields
}

func New

func New(o interface{}) Type

func (Type) Bool

func (t Type) Bool() bool

func (Type) Float32

func (t Type) Float32() float32

func (Type) Float64

func (t Type) Float64() float64

func (Type) Int

func (t Type) Int() int

func (Type) Int16

func (t Type) Int16() int16

func (Type) Int32

func (t Type) Int32() int32

func (Type) Int64

func (t Type) Int64() int64

func (Type) Int8

func (t Type) Int8() int8

func (Type) Interface added in v0.0.3

func (t Type) Interface() interface{}

func (Type) Map

func (t Type) Map() Map

func (Type) MapInt64 added in v0.0.4

func (t Type) MapInt64() MapInt64

func (Type) MapInterface added in v0.0.4

func (t Type) MapInterface() MapInterface

func (Type) MapString added in v0.0.4

func (t Type) MapString() MapString

func (Type) MapStringInterface added in v0.0.5

func (t Type) MapStringInterface() map[string]interface{}

func (Type) Slice

func (t Type) Slice() Slice

func (Type) SliceInt64 added in v0.0.4

func (t Type) SliceInt64() []int64

func (Type) SliceInterface added in v0.0.4

func (t Type) SliceInterface() []interface{}

func (Type) SliceMapStringInterface added in v0.0.5

func (t Type) SliceMapStringInterface() []map[string]interface{}

func (Type) SliceString added in v0.0.4

func (t Type) SliceString() []string

func (Type) String

func (t Type) String() string

func (Type) Uint

func (t Type) Uint() uint

func (Type) Uint16

func (t Type) Uint16() uint16

func (Type) Uint32

func (t Type) Uint32() uint32

func (Type) Uint64

func (t Type) Uint64() uint64

func (Type) Uint8

func (t Type) Uint8() uint8

Jump to

Keyboard shortcuts

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