Skip to content

Instantly share code, notes, and snippets.

@riston
Created July 25, 2015 09:02
Show Gist options
  • Save riston/2441b539dc8914a79007 to your computer and use it in GitHub Desktop.
Save riston/2441b539dc8914a79007 to your computer and use it in GitHub Desktop.
Convert map[string]interface{}
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