types

package
v0.0.0-...-f89cf20 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 5 Imported by: 0

README

Types

拓展类型定义,方便函数的定义,以及自定义方法,用户可以直接使用。

基本类型

type Interface interface{}

type Byte byte

type Int int
type Int64 int
type Int32 int32
type Int16 int16
type Int8 int8

type Uint uint
type Uint64 uint
type Uint32 uint32
type Uint16 uint16
type Uint8 uint8

type String string

type Float64 float64
type Float32 float32

type Bool bool

type Any = interface{}

type AnySlice = []Any
type InterfaceSlice = AnySlice

type ByteSlice = []byte

type IntSlice = []int
type Int64Slice = []int64
type Int32Slice = []int32
type Int16Slice = []int16
type Int8Slice = []int8

type UintSlice = []uint
type Uint64Slice = []uint64
type Uint32Slice = []uint32
type Uint16Slice = []uint16
type Uint8Slice = []uint8

type StringSlice = []string

type Float64Slice = []float64
type Float32Slice = []float32

type BoolSlice = []bool

Comparable 比较的接口

未来goproposal: spec: generic programming facilities引入泛型可以解决这个问题,但是很遗憾,可见的时间内不会有泛型

// Ordering is the result of a comparison between two values.
type Ordering int

const (
    // 小于
    OrderingLess    Ordering = -1
    // 等于
    OrderingEqual            = 0
    // 大于
    OrderingGreater          = 1
)

type Comparable interface{ Compare(o Comparable) Ordering }

目前上面定义的基本类型已经实现了 Comparable 同时xsort也使用到了Comparable

ID

type ID uint64
// 大端顺序的二进制结果
func (id ID) Binary() []byte
// 大端顺序的二进制结果的16进制的结果
func (id ID) Hex() string
// 大端顺序的二进制结果的base64的结果
func (id ID) Base64() string

Convert 类型转换

// int 数组到int64数组的转换
func IntSliceToInt64Slice(a types.IntSlice) types.Int64Slice
// int64 数组到int数组的转换
func Int64SliceToIntSlice(a types.Int64Slice) types.IntSlice
// int 数组到interface{}数组的转换
func IntSliceToAnySlice(a types.IntSlice) types.AnySlice
// int64 数组到interface{}数组的转换
func Int64SliceToAnySlice(a types.Int64Slice) types.AnySlice
// int 数组到string数组的转换
func IntSliceToStringSlice(a types.IntSlice) types.StringSlice
// int64 数组到string数组的转换
func Int64SliceToStringSlice(a types.Int64Slice) types.StringSlice
// string 数组到int数组的转换
func StringSliceToIntSlice(a types.StringSlice) (b types.IntSlice, hasErr bool)
// string 数组到int64数组的转换
func StringSliceToInt64Slice(a types.StringSlice) (b types.Int64Slice, hasErr bool)

Documentation

Index

Constants

View Source
const (
	OrderingLess    Ordering = -1
	OrderingEqual            = 0
	OrderingGreater          = 1
)

Variables

This section is empty.

Functions

func FormatIDList

func FormatIDList(ids []ID) (string, error)

func Init

func Init(salt string)

func ParseInt64List

func ParseInt64List(str string) ([]int64, error)

Types

type Any

type Any = interface{}

type AnySlice

type AnySlice = []Any

type Bool

type Bool bool

type BoolSlice

type BoolSlice = []bool

type Byte

type Byte byte

type ByteSlice

type ByteSlice = []byte

type Comparable

type Comparable interface{ Compare(o Comparable) Ordering }

type ComparableSlice

type ComparableSlice = []Comparable

type Float32

type Float32 float32

type Float32Slice

type Float32Slice = []float32

type Float64

type Float64 float64

type Float64Slice

type Float64Slice = []float64

type ID

type ID int64

func ParseIDList

func ParseIDList(str string) ([]ID, error)

func (ID) MarshalJSON

func (i ID) MarshalJSON() ([]byte, error)

func (ID) MarshalText

func (i ID) MarshalText() (text []byte, err error)

func (*ID) UnmarshalJSON

func (i *ID) UnmarshalJSON(data []byte) error

func (*ID) UnmarshalText

func (i *ID) UnmarshalText(text []byte) error

type Int

type Int int

func (Int) Compare

func (i Int) Compare(o Comparable) Ordering

type Int16

type Int16 int16

func (Int16) Compare

func (i Int16) Compare(o Comparable) Ordering

type Int16Slice

type Int16Slice = []int16

type Int32

type Int32 int32

func (Int32) Compare

func (i Int32) Compare(o Comparable) Ordering

type Int32Slice

type Int32Slice = []int32

type Int64

type Int64 int

func (Int64) Compare

func (i Int64) Compare(o Comparable) Ordering

type Int64Slice

type Int64Slice = []int64

type Int8

type Int8 int8

func (Int8) Compare

func (i Int8) Compare(o Comparable) Ordering

type Int8Slice

type Int8Slice = []int8

type IntSlice

type IntSlice = []int

type Interface

type Interface interface{}

type InterfaceSlice

type InterfaceSlice = AnySlice

type Ordering

type Ordering int

Ordering is the result of a comparison between two values.

type String

type String string

func (String) Compare

func (i String) Compare(o Comparable) Ordering

type StringSlice

type StringSlice = []string

type Uint

type Uint uint

func (Uint) Compare

func (i Uint) Compare(o Comparable) Ordering

type Uint16

type Uint16 uint16

func (Uint16) Compare

func (i Uint16) Compare(o Comparable) Ordering

type Uint16Slice

type Uint16Slice = []uint16

type Uint32

type Uint32 uint32

func (Uint32) Compare

func (i Uint32) Compare(o Comparable) Ordering

type Uint32Slice

type Uint32Slice = []uint32

type Uint64

type Uint64 uint

func (Uint64) Compare

func (i Uint64) Compare(o Comparable) Ordering

type Uint64Slice

type Uint64Slice = []uint64

type Uint8

type Uint8 uint8

func (Uint8) Compare

func (i Uint8) Compare(o Comparable) Ordering

type Uint8Slice

type Uint8Slice = []uint8

type UintSlice

type UintSlice = []uint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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