mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 20:40:25 +08:00
实现HTTP部分功能
This commit is contained in:
20
pkg/configutils/copy.go
Normal file
20
pkg/configutils/copy.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package configutils
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// 拷贝同类型struct指针对象中的字段
|
||||
func CopyStructObject(destPtr, sourcePtr interface{}) {
|
||||
value := reflect.ValueOf(destPtr)
|
||||
value2 := reflect.ValueOf(sourcePtr)
|
||||
|
||||
countFields := value2.Elem().NumField()
|
||||
for i := 0; i < countFields; i++ {
|
||||
v := value2.Elem().Field(i)
|
||||
if !v.IsValid() || !v.CanSet() {
|
||||
continue
|
||||
}
|
||||
value.Elem().Field(i).Set(v)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user