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

Multiple prefix() sections should not be automatically sorted #205

Open
SOF3 opened this issue Apr 8, 2024 · 3 comments
Open

Multiple prefix() sections should not be automatically sorted #205

SOF3 opened this issue Apr 8, 2024 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@SOF3
Copy link

SOF3 commented Apr 8, 2024

What version of GCI are you using?

0.13.4

Reproduce Steps

$ example.go
package example

import (
        _ "example.com/a/b"
        _ "example.com/i/j"
        _ "example.com/m/n"
        _ "example.com/p/q"
)

$ go run github.com/daixiang0/gci@v0.13.4 print example.go \
>       -s standard
>       -s default
>       -s 'prefix(example.com/i/j,example.com/m/n)'
>       -s 'prefix(example.com/a/b,example.com/p/q)'
package example

import (
        _ "example.com/a/b"
        _ "example.com/p/q"

        _ "example.com/i/j"
        _ "example.com/m/n"
)

What did you expect to see?

The sections should be consistent with the order of -ss passed.

What did you see instead?

The sections follow lexicographical order of the prefix() string. If I change the fourth section to prefix(example.com/p/q,example.com/a/b), the two sections in the output will be swapped.

@SOF3
Copy link
Author

SOF3 commented Apr 8, 2024

Possible workaround for now: add nosuchmodule/1, and nosuchmodule/2, after prefix( to force the order of prefixes.

@daixiang0
Copy link
Owner

The two prefix section does not follow lexicographical order which is written in the README, the strings in the prefix follow, so you can put then into one prefix section.

I think it is good to improve, you can take it if interested.

Label it as help wanted if someone else interested.

@daixiang0 daixiang0 added help wanted Extra attention is needed good first issue Good for newcomers labels Apr 8, 2024
@SOF3
Copy link
Author

SOF3 commented Apr 8, 2024

I don't understand. What is written in the readme? And what does "you can put them into one prefix section" mean? I am referring to multiple prefix sections, not multiple prefixes within the same section; the , part is just for illustration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants