Files
Go-http_framework/util/reflectM/Indirect.go
T
Huangzj 5d9b7282ab feat(Go-Tool):
2021/1/4 :reflectM包添加indirect处理指针和非指针,获取type、value
2021-01-04 15:49:21 +08:00

26 lines
551 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* @Author : huangzj
* @Time : 2021/1/4 15:44
* @Description
*/
package reflectM
import "reflect"
//获取value值,包含ptr的处理
func Indirect(reflectValue reflect.Value) reflect.Value {
for reflectValue.Kind() == reflect.Ptr {
reflectValue = reflectValue.Elem()
}
return reflectValue
}
//获取Type值,包含ptr的处理
func IndirectType(reflectType reflect.Type) reflect.Type {
for reflectType.Kind() == reflect.Ptr || reflectType.Kind() == reflect.Slice {
reflectType = reflectType.Elem()
}
return reflectType
}