Basic Type - GoblinBear/beson-go GitHub Wiki

Types

  • nil
  • UInt8 / Int8
  • UInt16 / Int16
  • UInt32 / Int32
  • UInt64 / Int64
  • Float32
  • Float64
  • Bool
  • String
  • Slice
  • Map

Initializes New Data

// boolean
b1 := types.NewBool(true)
b2 := types.NewBool(false)

// unsigned integer
un1 := types.NewUInt8(2)
un2 := types.NewUInt16(2)
un3 := types.NewUInt32(2)
un4 := types.NewUInt64(2)

// signed integer
si1 := types.NewInt8(-3)
si2 := types.NewInt16(-3)
si3 := types.NewInt32(-3)
si4 := types.NewInt64(-3)

// float
f1 := types.NewFloat32(0.456)
f2 := types.NewFloat64(0.456)

// string
str := types.NewString("Hello world")

// slice
slc := types.NewSlice([]types.RootType { 
    types.NewFloat32(0.456),
    types.NewInt32(-3),
})

// map
m := types.NewMap(map[string]types.RootType { 
    types.NewUInt8(2),
    types.NewBool(false),
})

Get Data Value

Call method Get()

v := types.NewUInt8(2)
data := v.Get()

Set Data Value

Call method Set()

v := types.NewUInt8(2)
v.Set(3)