Hello, everyone, homies, ladies, gentleman, turtles. I am making this post before sleeping, please make some good discussion till I wake up.
Ahem.
In the company I currently work for, we use FastAPI, and convention goes like this:
– project root
— src
— routers
—- user.py
— models
—- user_models.py
And, as you already guess lets say we have
async def ILoveMyDad()
router and
class ILoveMyDadRequest(BaseModel):
class ILoveMyDadResponse(BsseModel):
goes into two seperate folders and files.
Which… feels so wrong to me.
In GoLang, I recently started doing something like this:
If I have a struct, lets say
type ILoveMyMomRequest struct {}
and
type ILoveMyMomResponse struct {}
they go right on top of the endpoint
type ILoveMyMomRequest struct {}
type ILoveMyMomResponse struct {}
func ILoveMyMomEndpoint(w http ResponseWriter, yada yada.)
So, no seperate folders and files.
– project root
— src
— core
—- users.go
and that is it.
What do you all think about this?
Should a struct go right on top of the function, if that struct is only specific to that function? Or should every struct go into separate folders and files with their common purposes grouped together like users_model.py?