vendredi 17 août 2018

What is the best method to instantiate a struct in run time?

I am currently writing a cache wrapper which will read the config and return what is the cache type (redis/memecache)

Now I have redis.go and memcache.go which has functions like

initialize(), getCache(), setCache()

My cache wrapper is my entry point and it returns

Redis or Memcache as a "string"

as output. Now I want to call the initialize function of either redis/ memcache depending on the string. How do I do it?

Aucun commentaire:

Enregistrer un commentaire