Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: suggested import organization: separate by network or by purpose? #3521

Open
moul opened this issue Jan 15, 2025 · 2 comments
Open

RFC: suggested import organization: separate by network or by purpose? #3521

moul opened this issue Jan 15, 2025 · 2 comments
Labels
❓ question Questions about Gno

Comments

@moul
Copy link
Member

moul commented Jan 15, 2025

We're discussing the best way to organize imports in Gno projects. There are three main approaches under consideration:

  1. Separate by purpose (e.g., p/, r/)
    This organizes imports based on module type.

  2. Separate by network
    This keeps all imports together but categorizes them by the network they interact with.

  3. No separation

We'd like to gather feedback and opinions to determine our preferred standard for import organization. Please share your thoughts or any other suggestions.

Related: #2510 (comment)

@notJoon
Copy link
Member

notJoon commented Jan 15, 2025

I usually organize imports by combining styles 1 and 2. For example, if I import 'p' and 'r' from both gno demo packages and custom packages, I apply the following style:

import (
    "std"      // normal packages, as is go's convention
    "strings"

    "gno.land/p/demo/ufmt"  // gno demo packages. 'p' takes precedence over 'r'. Sorted alphabetically
    "gno.land/r/demo/users"

    "gno.land/p/foo/bar"        // custom packages are separated from demo. Same sorting order as above
    "gno.land/r/xyz/baz"
)

@thehowl
Copy link
Member

thehowl commented Jan 16, 2025

I think we should suggest, even in gno fmt, the import separation similar to Go:

  1. standard libraries
  2. internal imports from project (ie. module or sub-paths of the module)
  3. external imports

In each we should then divide alphabetically, which would implicitly split within the same "stanza" between p/, r/, as well as different networks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Questions about Gno
Projects
Status: Triage
Development

No branches or pull requests

3 participants