All

测试用

MrSnake
2021-12-22 / 2 评论 / 174 阅读 / 正在检测是否收录...

test

test

reflect包

type t struct {
    name string
}
reflect.Typeof(t)    // main.t
reflect.Kind(t)    // struct

1.Typeof指变量所属的类型,Kind指变量所属的类别。

const (Invalid Kind = iota,Bool,Int,Int8,Int16,Int32,Int64,Uint,Uint8,Uint16,Uint32,Uint64,Uintptr,Float32,Float64,Complex64,Complex128,Array,Chan,Func,Interface,Map,Ptr,Slice,String,Struct,UnsafePointer)

2.修改接口实际变量的值

Elem()获取指向原变量的指针

reflect.ValueOf(a).Elem().SetInt(38)

时间转换

todayZero, _ := time.ParseInLocation("2006-01-02", "2021-11-26 15:22:22" time.Local)
2

评论 (2)

取消
  1. 头像
    MrSnake 作者
    Windows 10 · Google Chrome

    画图

    回复
  2. 头像
    1
    Windows 10 · Google Chrome

    555

    回复