Skip to content

Same approach but flat structure? #55

Answered by benbjohnson
pegeraw asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @pegeraw, good questions.

Is it good idea if there is about 5-10k sloc in project?

I think a flat package structure is generally fine for small projects (e.g. <10KLOC). The main benefit for splitting out subpackages is isolation and that's not as critical when you don't have much code to isolate from each other.

What would You do when for example mongo and Postgres needs slightly different fields types, let’s say user Id will be different type for mongo and postgres. Should I put two user types in user.go file and two interfaces? One for Postgres and memory and one for mongo?

If your data layers need different different input types then I would create unexported types for each one …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@pegeraw
Comment options

@benbjohnson
Comment options

@pegeraw
Comment options

@pegeraw
Comment options

@benbjohnson
Comment options

Answer selected by benbjohnson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants