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

cmd/go: add sort for go.mod after 'go mod tidy' #30897

Closed
guhan121 opened this issue Mar 18, 2019 · 2 comments
Closed

cmd/go: add sort for go.mod after 'go mod tidy' #30897

guhan121 opened this issue Mar 18, 2019 · 2 comments
Labels
FrozenDueToAge modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@guhan121
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.11.1 darwin/amd64

$go env
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

after run go mod tidy
the go.mod file is modified!
But if you diff it with last version by git tools,you can't see the change clearly。

i hope add a rule for sort lines in go.mod !

@ALTree ALTree added this to the Go1.13 milestone Mar 19, 2019
@ALTree ALTree added the modules label Mar 19, 2019
@ALTree ALTree changed the title add sort for go.mod after 'go mod tidy' cmd/go: add sort for go.mod after 'go mod tidy' Mar 19, 2019
@bcmills
Copy link
Contributor

bcmills commented Mar 28, 2019

go commands that edit the go.mod file do preserve sort order within each block. Could you give a concrete example for which the result ends up unsorted?

sort.Slice(block.Line, func(i, j int) bool {
li := block.Line[i]
lj := block.Line[j]
for k := 0; k < len(li.Token) && k < len(lj.Token); k++ {
if li.Token[k] != lj.Token[k] {
return li.Token[k] < lj.Token[k]
}
}
return len(li.Token) < len(lj.Token)
})

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 28, 2019
@guhan121
Copy link
Author

guhan121 commented Apr 1, 2019

oh! sorry, because the go.mod in our project edit by developers not use go mod tidy,so it not sort.
i check the go.mod file. it is sorted!
As shown in the figure below:
On the left is developer submissions!
On the right is go mod tidy

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants