mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-01-11 16:22:45 +00:00
Some checks are pending
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Release 3X-UI / Build for Windows (push) Waiting to run
* refactor: use any instead of empty interface * refactor: code cleanup
24 lines
675 B
Go
24 lines
675 B
Go
// Package reflect_util provides reflection utilities for working with struct fields and values.
|
|
package reflect_util
|
|
|
|
import "reflect"
|
|
|
|
// GetFields returns all struct fields of the given reflect.Type.
|
|
func GetFields(t reflect.Type) []reflect.StructField {
|
|
num := t.NumField()
|
|
fields := make([]reflect.StructField, 0, num)
|
|
for i := range num {
|
|
fields = append(fields, t.Field(i))
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// GetFieldValues returns all field values of the given reflect.Value.
|
|
func GetFieldValues(v reflect.Value) []reflect.Value {
|
|
num := v.NumField()
|
|
fields := make([]reflect.Value, 0, num)
|
|
for i := range num {
|
|
fields = append(fields, v.Field(i))
|
|
}
|
|
return fields
|
|
}
|