Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

How to handle key conflicts when using mapstructure:",squash" ? #356

Description

@dangquyitt
type Order struct {
	Id string
}

type User struct {
	Id    string
	Order Order `mapstructure:",squash"`
}

result := map[string]interface{}{}
mapstructure.Decode(User{
	Id: "userId",
	Order: Order{
		Id: "orderId",
	},
}, &result)

log.Println(result)
Output: map[Id:orderId]
Expected: map[Id:userId Order.Id:orderId]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions