Where do config and router files belong to?

Hi,

My current application structure looks like below. The question I have is about config.go and router.go files. I wonder if they are misplaced as far as Go goes. The config.go loads application configuration vars from .env file one off. The router.go lists all the endpoint routes for the HTTP server and they get loaded one off too.

Are they in right place or do they belong to /cmd/api/ or /internal/app/ folder?

Note: Currently main.go is designed as a “bootstrap” file that prepares application dependencies. The api.go file is responsible for starting and shutting down the HTTP server. Based on this current setup, I have a strong feeling that the config.go and router.go files belong to /cmd/api/ folder as they are part of bootstrapping flow but still need experienced input.

Thanks

api
  |_ cmd
    |_ api
      |_ main.go
  |_ internal
    |_ app
    | |_ api.go
    |_ league
    | |_ create.go
    | |_ read.go
    |_ team
    | |_ update.go
    | |_ delete.do
    |_ pkg
      |_ config
      |  |_ config.go
      |_ router
         |_ router.go
Makefile
Readme.md
.env

I do my best to follow this.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.