3 ms·
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 mov
by emourujarvi 8y 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?
- dullgiulio 8y agoSort 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...
- emourujarvi 8y agoThanks! 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...
- steQ 8y agoIf you have never tried Gin why suggest to use something else?