As suggested by Kurtis Rader, I would use "reflection" for this. Here is a simple example (not fully tested, probably not safe, not production ready... so just for demonstration purpose) :
https://play.golang.org/p/sAyBajxsTAN -- Jacques -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b3a3d328-22a4-4698-9cac-99a8e7960fec%40googlegroups.com.