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

Comment after imports gets removed #123

Closed
mhofstetter opened this issue Nov 16, 2022 · 2 comments
Closed

Comment after imports gets removed #123

mhofstetter opened this issue Nov 16, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@mhofstetter
Copy link
Contributor

What version of GCI are you using?

v0.8.3

Reproduce Steps

Executing gci on the following source code removes the comment // Test on the struct which is following the imports.

It seems as the changed parsing logic is not respecting comments which might exist on a top level declaration: https://github.com/daixiang0/gci/blob/master/pkg/parse/parse.go#L115-L117

package main

import (
	"fmt"
	_ "github.com/golang" // golang
	"github.com/daixiang0/gci"
)

// Test
type Test struct {
}

->

package main

import (
	"fmt"

	_ "github.com/golang" // golang

	"github.com/daixiang0/gci"
)

type Test struct {
}

What did you expect to see?

Only imports should be modified - comments of following declarations (e.g. structs) should not be removed.

What did you see instead?

The comment of following declarations (e.g. structs) are getting removed.

@daixiang0 daixiang0 added the bug Something isn't working label Nov 16, 2022
@mhofstetter
Copy link
Contributor Author

I saw that #120 mentions the following

introduce breaking change: remove isolated comments

but i don't think that this is an "isolated comment"

@daixiang0
Copy link
Owner

daixiang0 commented Nov 16, 2022

#124 would fix this, thanks for report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants