damasdev / go-hexagonal-architecture

Go-Lang Hexagonal Architecture (also known as Ports and Adapters)
https://alistair.cockburn.us/hexagonal-architecture/
Apache License 2.0
19 stars 1 forks source link

Just a Little Comment #1

Open Hidayathamir opened 2 months ago

Hidayathamir commented 2 months ago

This line of code.

If you have more than one port, for example, product, how would you import that port?

portProduct "github.com/damasdev/go-hexagonal-architecture/internal/core/ports/product" ?

I think if you allow people to rename the import, each team member can import the package with a different name, which will quickly become a mess.

damasdev commented 2 months ago

To maintain consistency and avoid confusion, it's a good practice to establish a naming convention for imports within your team. Here's an example of how you might import multiple ports with consistent naming:

import (
    "errors"

    portUser "github.com/damasdev/go-hexagonal-architecture/internal/core/ports/user"
    portProduct "github.com/damasdev/go-hexagonal-architecture/internal/core/ports/product"
)

or:

import (
    "errors"

    "github.com/damasdev/go-hexagonal-architecture/internal/core/ports/user"
    "github.com/damasdev/go-hexagonal-architecture/internal/core/ports/product"
)

By following this convention, all team members will use the same aliases, reducing the risk of confusion and inconsistency.