cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.27k stars 3.63k forks source link

Proposal: Create packages directory #14143

Closed tac0turtle closed 1 year ago

tac0turtle commented 1 year ago

In light of many things being spun out into their own go.mod or package, I'd like to propose packages like errors math collections are put into a packages directory to not increase the size of the root directory.

itsdevbear commented 1 year ago

🙏 +1

julienrbrt commented 1 year ago

How are we defining the split? Personally I prefer how we have it now.

Here's some thoughts: https://github.com/golang-standards/project-layout/issues/10

aaronc commented 1 year ago

The downside is increasing import length and maybe breaking some code. Don't have a strong opinion though

tac0turtle commented 1 year ago

Wont import length stay the same with vanity urls?

aaronc commented 1 year ago

Maybe you're right, not 100% sure. We should do a test case.

tac0turtle commented 1 year ago

How are we defining the split? Personally I prefer how we have it now.

Here's some thoughts: golang-standards/project-layout#10

reading the issue, it looks like the conclusion is do what you think is best for your project. There are equally enough pros and cons for both.

The reason I was thinking about this is I'm not a fan of massive root directories and with vanity urls they can be imported under what evert we would like

itsdevbear commented 1 year ago

A golang "standard" was never really created.

I personally adhere to the pkg and internal heuristic fairly closely, gives our repos a sense of orderliness and hierarchy.

A massive root directory (in my opinion) prevents the repo from having a "flow". Sounds cheesy, but the repo file structure should read like a logically ordered book.

tac0turtle commented 1 year ago

before making the final call we should make sure Cosmossdk.io/math would still work with a directory path of cosmos-sdk/pkg/math

tac0turtle commented 1 year ago

looking into this, urls would need to change, so its not worth making this breaking change for users

itsdevbear commented 1 year ago

no stress, not that serious

robert-zaremba commented 1 year ago

for the record, I think the current layout is better. It's a Go project, so there is no need for root directories like src or packages. Moreover every directory, in go standard, is a package.