Skip to content

Instantly share code, notes, and snippets.

@srfrog
Created July 30, 2014 08:19
Show Gist options
  • Save srfrog/dd47071d401810a37e5d to your computer and use it in GitHub Desktop.
Save srfrog/dd47071d401810a37e5d to your computer and use it in GitHub Desktop.
find if a method is defined within an struct saved as interface{}
v := reflect.ValueOf(self.collection)
if m := v.MethodByName("Create"); m.IsValid() {
handler := m.Interface().(func(ResponseWriter, *Request))
self.Route("POST", "", handler)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment