gf/geg/container/gvar/g.var.go

37 lines
544 B
Go
Raw Normal View History

2018-10-10 15:24:30 +08:00
package main
import (
"gitee.com/johng/gf/g"
"fmt"
)
func main() {
var v g.Var
v.Set("123")
fmt.Println(v.Val())
// 基本类型转换
fmt.Println(v.Int())
fmt.Println(v.Uint())
fmt.Println(v.Float64())
// slice转换
fmt.Println(v.Ints())
fmt.Println(v.Floats())
fmt.Println(v.Strings())
// struct转换
type Score struct {
Value int
}
s := new(Score)
v.Struct(s)
fmt.Println(s)
// 只读接口
r := v.ReadOnly()
fmt.Println(r.String())
2018-10-10 15:24:30 +08:00
}