mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 13:18:01 +08:00
37 lines
544 B
Go
37 lines
544 B
Go
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())
|
|
}
|