Created
July 25, 2015 09:02
-
-
Save riston/2441b539dc8914a79007 to your computer and use it in GitHub Desktop.
Convert map[string]interface{}
This file contains hidden or 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
var profile OAuthProfile | |
MapToStruct(result, &profile) | |
fmt.Println("Extracted", profile) | |
func MapToStruct(m map[string]interface{}, val interface{}) error { | |
tmp, err := json.Marshal(m) | |
if err != nil { | |
return err | |
} | |
err = json.Unmarshal(tmp, val) | |
if err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment