MCPcopy Index your code
hub / github.com/TruthHun/BookStack / CopyObject

Function CopyObject

utils/util.go:889–913  ·  view source on GitHub ↗
(src, dst interface{})

Source from the content-addressed store, hash-verified

887}
888
889func CopyObject(src, dst interface{}) {
890 var srcMap = make(map[string]ReflectVal)
891
892 vs := reflect.ValueOf(src)
893 ts := reflect.TypeOf(src)
894 vd := reflect.ValueOf(dst)
895 td := reflect.TypeOf(dst)
896
897 ls := vs.Elem().NumField()
898 for i := 0; i < ls; i++ {
899 srcMap[ts.Elem().Field(i).Name] = ReflectVal{
900 T: vs.Elem().Field(i).Type(),
901 V: vs.Elem().Field(i),
902 }
903 }
904
905 ld := vd.Elem().NumField()
906 for i := 0; i < ld; i++ {
907 n := td.Elem().Field(i).Name
908 t := vd.Elem().Field(i).Type()
909 if v, ok := srcMap[n]; ok && v.T == t && vd.Elem().Field(i).CanSet() {
910 vd.Elem().Field(i).Set(v.V)
911 }
912 }
913}
914
915func RangeNumber(val, min, max int) int {
916 if val > max {

Callers 14

loginMethod · 0.92
RegisterMethod · 0.92
getFansOrFollowMethod · 0.92
UserInfoMethod · 0.92
UserReleaseBookMethod · 0.92
SearchBookMethod · 0.92
SearchDocMethod · 0.92
BookInfoMethod · 0.92
BookMenuMethod · 0.92
BookListsMethod · 0.92
BookListsByCidsMethod · 0.92
ReadMethod · 0.92

Calls 1

SetMethod · 0.80

Tested by

no test coverage detected