Skip to content

Instantly share code, notes, and snippets.

@darthberen
Last active August 29, 2015 14:07
Show Gist options
  • Save darthberen/c5a7701ee1d3a394d78f to your computer and use it in GitHub Desktop.
Save darthberen/c5a7701ee1d3a394d78f to your computer and use it in GitHub Desktop.
go map comparisons problem
type Doc struct {
Map map[string]string `json:"map"`
}
func main() {
// source is a JSON document from an external service
var doc Doc
json.Unmarshal(source, &doc)
SomeFunc(doc.Map)
}
func SomeFunc(paramMap map[string]string) {
compMap := map[string]string{}
if reflect.DeepEqual(paramMap, compMap) {
// why does this not execute when expected?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment