Created
August 22, 2018 03:20
-
-
Save eklitzke/deaefd23a5a1b31a5c320abc12c1595c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PushType represents a value that can be pushed into the hierarchy. | |
type PushType map[string]interface{} | |
func init() { | |
gob.Register(PushType{}) | |
} | |
var errBadPushCast = errors.New("bad push cast") | |
// go is so fucking stupid | |
func castToPushType(val interface{}) (PushType, error) { | |
var p PushType | |
if mapVal, ok := val.(map[string]interface{}); ok { | |
for k, v := range mapVal { | |
p[k] = v | |
} | |
return p, nil | |
} | |
return p, errBadPushCast | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do something like: