golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.4k stars 17.7k forks source link

x/tools/go/packages: GoFiles should be sorted #36763

Closed perillo closed 4 years ago

perillo commented 4 years ago

The GoFiles field in packages is the concatenation of GoFiles and CgoFiles from go list. go list returns the two fields sorted (although it seems to not be documented), but packages does not sort its own GoFiles.

mvdan commented 4 years ago

Could you clarify why you think this is important? Is it for consistency with go list, or to have deterministic behavior?

perillo commented 4 years ago

The order returned by packages is deterministic. It is just not the order one may expect.

cagedmantis commented 4 years ago

/cc @matloob

matloob commented 4 years ago

I'd prefer not to specify the ordering of GoFiles. We want it to be deterministic but I think that otherwise, the more flexibility the api has, the better.

perillo commented 4 years ago

It seems reasonable, and go help list does not document that the files are sorted.

Thanks.

matloob commented 4 years ago

Okay, I'll close. Thanks!