Golang对象的静态与动态绑定

I have this application where requests are filtered based on the string in the struct and made to execute different functions.

My approach is to have a Map which maps the strings to the function pointers and execute them. However this approach is being contended by a teammate who wants to do this filtering by reflection. We are using Go and it is for monitoring the activity of our site.

Teammates approach: Use reflection to switch the object based on the string, pass the string to the function and let the function call the relevant function. My approach: Simple map from string to functions

Any help is appreciated.

Downside of reflection based auto-discovery is that you forever have to be careful on what you add to the system because it can be automatically picked up.

vs map approach where you would need to explicitly expose each function.

Reflection is more cool and auto-magical, for sure. But auto-magical doesn't lend it self very well to security or long term maintainability.

Plus, a map[string]func(with specific signature) won't compile if you attempt register a non-matching function.

Where you will find stuff with reflection and then ponder why it's a runtime fail.