package db import ( "reflect" ) func StructPointers(s interface{}) []interface{} { model := reflect.ValueOf(s) modelElem := model.Elem() numFields := modelElem.NumField() var Ptrs []interface{} for i := 0; i < numFields; i++ { field := modelElem.Field(i) tag := modelElem.Type().Field(i).Tag if tag != "" { continue } // Merge if field.Kind() == reflect.Struct { Ptrs = append(Ptrs, StructPointers(field.Addr().Interface())...) continue } Ptrs = append(Ptrs, field.Addr().Interface()) } return Ptrs }