We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I found a bug when a structure having method. For the example,
Find the User struct in sample code
User
type User struct { Username string `json:"username" groups:"api"` Email string `json:"email"` Name string `json:"name" groups:"api"` Roles []string `json:"roles" groups:"api"` }
Add the following code below,
func (u User) String() string { return fmt.Sprintf("User<%s %s>", u.Username, u.Name) }
It will brick the scoping, marshal all the stuff into json.
The text was updated successfully, but these errors were encountered:
type User struct { Username string `json:"username" groups:"api"` Email string `json:"email"` Name string `json:"name" groups:"api"` Roles []string `json:"roles" groups:"api"` } func (u User) String() string { return fmt.Sprintf("User<%s %s>", u.Username, u.Name) } func TestMarshal_User(t *testing.T) { u := &User{ Username: "test", Email: "[email protected]", Name: "tester", Roles: []string{"admin"}, } v, err := Marshal(&Options{Groups: []string{"api"}}, u) assert.NoError(t, err) assert.Equal(t, map[string]interface{}{"name":"tester", "roles":[]interface {}{"admin"}, "username":"test"}, v) }
This looks correct to me. Please clarify what the issue is or provide a PR. Until then, I close the issue.
Sorry, something went wrong.
No branches or pull requests
Hi, I found a bug when a structure having method.
For the example,
Find the
User
struct in sample codeAdd the following code below,
It will brick the scoping, marshal all the stuff into json.
The text was updated successfully, but these errors were encountered: