mardi 17 février 2015

Go language: How to change method implementation in run-time using reflection?

I have this type implementation:



type A struct{
name string
}

func (a A) getName() string {
return "My name is " + a.name
}


How I can change implementation of method getName() for this type using reflection? For example, I want use next implementation instead of current:



func newGetName() string {
return "test reflection"
}





Aucun commentaire:

Enregistrer un commentaire