Hacker News new | ask | show | jobs
by emourujarvi 2765 days ago
When using a single folder structure, how should one go about creating multiple functions with a same name?

I'm creating a web service with Gin, and I have moved each http request handler into its own file. I would like to be able to pass these request handlers to Gin's router with pageA.Handler, pageB.Handler, pageC.Handler, etc, but compiler won't let me because function names have to be unique. Creating unique names for each handler function works fine, but personally it somehow feels messy.

Am I thinking anti-golang way, if I want to namespace these request handlers?

1 comments

Sort of yes. I have never tried Gin and I actually suggest you to use something else, like gorilla/mux, but that said what you describe sounds like several types implementing an interface...
If you have never tried Gin why suggest to use something else?
Thanks! I didn't know gorilla/mux even existed. I've mostly followed some blog examples in creating my web app, and I guess it shows...