func GetFromDB(tableName string, m *bson.M) interface{} {
var (
__session *mgo.Session = getSession()
)
//if the query arg is nil. give it the null query
if m == nil {
m = &bson.M{}
}
__result := []interface{}{}
__cs_Group := __session.DB(T_dbName).C(tableName)
__cs_Group.Find(m).All(&__result)
return __result
}
GetFromDB(T_cs_GroupName, &bson.M{"Name": "Alex"}).([]CS_Group)
運行時將會給我恐慌:
panic: interface conversion: interface is []interface {}, not []mydbs.CS_Group
如何返回值轉換爲我的結構?
可能重複的[類型轉換中的接口切片](http://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces-in-go) – kostix 2014-10-01 17:20:51