0x4a52466c696e74 2 meses atrás
pai
commit
2bc5273176
2 arquivos alterados com 4 adições e 3 exclusões
  1. 1 1
      serialize.go
  2. 3 2
      z_test.go

+ 1 - 1
serialize.go

@@ -74,7 +74,7 @@ func parseType(from, to reflect.Value, fieldName string) IErrorArgs {
 func realValue(val reflect.Value) reflect.Value {
 	if val.Kind() == reflect.Ptr || val.Kind() == reflect.Interface {
 		//if val.Kind() == reflect.Interface {
-		if val.IsNil() && val.Kind() == reflect.Ptr {
+		if val.IsNil() && val.Kind() == reflect.Ptr && val.CanSet() {
 			val.Set(reflect.New(val.Type().Elem()))
 		}
 		// check

+ 3 - 2
z_test.go

@@ -406,6 +406,7 @@ type AuthEmail struct {
 	Email     string `rest:"required" example:"mail@mail.ml"`
 	ThemeName string `rest:"required"`
 	UUser     *User
+	Fields    []any
 }
 
 func (s *AuthEmail) Validate(req IRequestIn) IRequestOut {
@@ -434,8 +435,8 @@ func TestSerializeEmail(t *testing.T) {
 		"email":     "flint@77i.su",
 		"themeName": "th-name",
 		"UUser": json.Map{
-			"ID":       100,
-			"Name":     "User 100",
+			"ID": 100,
+			//"Name":     "User 100",
 			"Created":  "10.11.1983 03:12",
 			"ParentID": nil,
 		},