Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when param of map mismatch #2672

Closed
chowyu12 opened this issue Dec 7, 2022 · 2 comments · Fixed by #2681
Closed

panic when param of map mismatch #2672

chowyu12 opened this issue Dec 7, 2022 · 2 comments · Fixed by #2681

Comments

@chowyu12
Copy link
Contributor

chowyu12 commented Dec 7, 2022

go-zero v1.4.2

error:
panic: reflect.Value.SetMapIndex: value of type interface {} is not assignable to type string

image

test code:

        type Req struct {
		Params map[string]string `json:"params"` // 参数
	}

	var req Req
	body := `{"params":{"a":{"a":123}}}`
	err := mapping.UnmarshalJsonReader(strings.NewReader(body), &req)
	if err != nil {
		fmt.Println(err)
		return
	}
@chowyu12
Copy link
Contributor Author

chowyu12 commented Dec 7, 2022

@anqiansong @kevwan

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@anxi sends @Kev to play

kevwan added a commit to kevwan/go-zero that referenced this issue Dec 8, 2022
@kevwan kevwan linked a pull request Dec 8, 2022 that will close this issue
kevwan added a commit to kevwan/go-zero that referenced this issue Dec 10, 2022
kevwan added a commit to kevwan/go-zero that referenced this issue Dec 10, 2022
kevwan added a commit that referenced this issue Dec 10, 2022
* fix: #2672

* chore: fix more cases

* chore: update deps

* chore: update deps

* chore: refactor

* chore: refactor

* chore: refactor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants