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

Conflict Between GCI and VSCode Go Extension: Blank Line Handling in Import Groups #216

Open
nicanorflavier opened this issue Sep 27, 2024 · 2 comments

Comments

@nicanorflavier
Copy link

nicanorflavier commented Sep 27, 2024

Issue:

gci does not allow a blank line between external and local module packages, which conflicts with VSCode's Go extension. The Go extension automatically adds a blank line between different groups of imports (e.g., external and local module packages) for readability. As a result, gci reports that the blank line should be removed, while the Go extension insists on adding it back, causing a conflict between the two tools.

What version of GCI are you using?

gci version 0.13.4

Reproduce Steps

  1. Create Go imports with external and local module packages, e.g.:
import (
	"github.com/labstack/echo/v4"
	"go.uber.org/zap"
	"mymicroservice_service/internal/config"
)
  1. Run gci list or gci diff – it passes.
  2. Open the file in VSCode with the Go extension installed.
  3. Save the file (CTRL+S) – the Go extension adds a blank line between the import groups.
  4. Run gci list or gci diff again – it fails, asking you to remove the blank line.

Open this in Visual

What did you expect to see?

gci should align with developer workflows and the Go extension's formatting by allowing the blank line between different import groups.

What did you see instead?

gci asks to remove the blank line between external and local module package imports.

@daixiang0
Copy link
Owner

I guess you do not set the import group, you can read the readme to set the group then vscode extension would not add blank.

@nicanorflavier
Copy link
Author

nicanorflavier commented Oct 2, 2024

I guess you do not set the import group, you can read the readme to set the group then vscode extension would not add blank.

You suggesting a fix that is not by default in vscode go extension rather than fixing this in gci to accomodate the developers workflow. Up to you, but I believe the devs would likely just disable this in .golangciyml if this is how you wanted it to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants