hskiba icon

GetStructModifiableFields

hskiba | PRO | 10/07/21 11:09:33 AM UTC | 0 ⭐ | 15637 👁️ | Never ⏰ | []
Go |

370 B

|

None

|

0 👍

/

0 👎

// GetStructModifiableFields returns an array of field names that do not have a
// readonly:"true" struct tag
func GetStructModifiableFields(s interface{}) (fields []reflect.StructField) {
    structFields := reflect.VisibleFields(reflect.TypeOf(s))
    for _, f := range structFields {
        if f.Tag.Get("readonly") != "true" {
            fields = append(fields, f)
        }
    }
    return
}
 

Comments