Skip to content

util/gconv: After conversion, the interface{} type becomes *interface {} #3731

@aundis

Description

@aundis

Go version

go version go1.18 windows/amd64

GoFrame version

v2.7.2

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

package main

import (
	"fmt"

	"github.com/gogf/gf/v2/util/gconv"
)

func main() {
	req := map[string]any{
		"id": "123",
		"doc": map[string]any{
			"craft": nil,
		},
		"fields": []string{"_id"},
	}

	var args *UpdateByIdReq
	err := gconv.Struct(req, &args)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%T", args.Doc["craft"])
}

type UpdateByIdReq struct {
	Id     string                 `json:"id" v:"required|length:24,24#id长度错误"`
	Doc    map[string]interface{} `json:"doc" v:"required"`
	Fields []string               `json:"fields"`
}

What did you see happen?

输出 *interface {}

What did you expect to see?

应该是 interface{}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIt is confirmed a bug, but don't worry, we'll handle it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions