Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a defect while using struct tags to name dependencies - struct tags are static as hard-coded, sometimes we may need to choose a dependency by a dynamic name according to external configuration, but struct tags can't be changed.

Some days ago I had some thoughts on dependency injection and made a tiny library as well, just for reference: https://github.com/go-tk/di



Reading from config isn’t a problem with the way I am doing it… the name is only the key for the thing to inject, you need some code to fill that key to something else dynamically already.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: