What do you keep in the _internal_ package?

Hello everyone,

What do you keep in the /internal directory ? Do you keep validation helpers, or database models ?

How does that rely to the DDD paradigm ? Do you store domain logic in the /internal package ?

Hi @heidi ,

The /internal directory is recognized by the Go compiler as a special directory. Packages inside /internal cannot be accessed by other projects.

By putting packages into /internal, you reduce your public API surface.

The point is, if your project is public, sooner or later, other people will start using the public packages of your project, whether or not you intended all of these packages for reuse by others. This can increase the burden of maintenance and reduce your ability to change the package API as you like.

So if you have packages that you do not want to maintain for others, and that are likely to change their package API, put them into /internal.

(More on Go project layouts here.)

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