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

Add support for multi-line comments #13

Closed
MatthewDolan opened this issue Sep 1, 2020 · 2 comments
Closed

Add support for multi-line comments #13

MatthewDolan opened this issue Sep 1, 2020 · 2 comments

Comments

@MatthewDolan
Copy link

MatthewDolan commented Sep 1, 2020

When running this formatter against our code, we noticed that it was removing all but the last line from multi-line block comments on imports.

It looks like this is referenced as a TODO in the README ("Support multiple lines of comment in import block"), but just wanted to call it out as an explicit issue / feature request.

Example

For example, for a file like this:

package example

import (
	// A block comment about why this package is being imported.
	//
	// More information about why this package is being imported.
	_ "github.com/example/nested"
)
...

Expected output

We expected nothing to happen to this file. The multi-line comment block would be treated as associated with the import below it and kept together.

Actual output

The formatter removes all but the last line of the comment.

> gci -d .
diff -u example.go.orig example.go
--- example.go.orig	2020-09-01 08:10:37.000000000 -0700
+++ example.go	2020-09-01 08:10:37.000000000 -0700
@@ -1,8 +1,7 @@
 package example
 
 import (
-	// A block comment about why this package is being imported.
-	//
+
 	// More information about why this package is being imported.
 	_ "github.com/example/nested"
 )
@daixiang0
Copy link
Owner

It may be hard to implement only with string detect, AST may help it.

@daixiang0
Copy link
Owner

After #50, GCI would not format those :)

Feel free to reopen it if still exist.

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

Successfully merging a pull request may close this issue.

2 participants