You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
however, this test has no assertions but rather a comment of what it "should" be without validation. I want to make sure mapstructure "should not" be returning fields that are flagged with omitted. If so I am willing to send a PR, but want to make sure that I am understanding the library correctly.
I ran the following code:
package main
import (
"fmt""github.com/mitchellh/mapstructure"
)
typeJobstruct {
Titlestring`mapstructure:"title,omitempty"`
}
typePersonstruct {
Namestring`mapstructure:"name"`Age*int`mapstructure:"age,omitempty"`*Job`mapstructure:",omitempty"`
}
funcmain() {
m:=&map[string]interface{}{}
p:=Person{Name: "rockets"}
err:=mapstructure.Decode(&p, m)
iferr!=nil {
fmt.Println("received an error while decoding", err)
return
}
fmt.Println(m)
}
// returns: &map[Job:<nil> age:<nil> name:rockets]
The text was updated successfully, but these errors were encountered:
Thank you for this project,
I am looking for verification on an assumption I have when it comes to the
omitempty
flag in mapstructure.Assumption: I expect any property that has the
omitempty
flag would be "omitted" from the map that is populated by mapstructure.I reference this test
mapstructure/mapstructure_examples_test.go
Line 255 in 07998cf
however, this test has no assertions but rather a comment of what it "should" be without validation. I want to make sure mapstructure "should not" be returning fields that are flagged with omitted. If so I am willing to send a PR, but want to make sure that I am understanding the library correctly.
I ran the following code:
The text was updated successfully, but these errors were encountered: