interface{} 转为普通类型我们都知道在golang中interface{}可以代表任何类型,对于像int64、bool、string等这些简单类型,interface{}类型转为这些简单类型时,直接使用p, ok := t.(bool)p, ok := t.(int64)如果ok==tru...
我就废话不多说了,大家还是直接看代码吧~type Animal struct { ID int64 Name string `gorm:'default:’galeone’'` Age int64} 把 name 设置上缺省值 galeone 了。补充:Golang 巧用构造函数设置结构体的默认值看...
直接上代码:1. 第一种情况如果没有select{}, main 主线程不会等待coroutine运行,导致coroutine得不到机会运行。You are requesting eventual scheduling (using the two go statements)of two goro...