Exemplo n.º 1
0
func TestIsEmpty(t *testing.T) {
	//a := ""
	b := make(map[string]string)
	b["a"] = "a"
	isEmpty := utils.IsEmpty(b)
	fmt.Print("==============", isEmpty)
}
Exemplo n.º 2
0
func AsJSON(models []IModel) []map[string]interface{} {
	result := []map[string]interface{}{}
	if utils.IsEmpty(models) {
		return result
	}

	for _, val := range models {
		result = append(result, val.AsJSON())
	}

	return result

}
Exemplo n.º 3
0
func Slice(i interface{}, properties ...string) map[string]interface{} {
	result := make(map[string]interface{})
	if utils.IsEmpty(i) {
		return result
	}
	val := reflect.ValueOf(i)
	sInd := reflect.Indirect(val)
	for _, k := range properties {
		field := sInd.FieldByName(k)
		result[k] = field.Interface()
	}

	return result
}