Import sorting

Skip to first unread message

Nikhil Benesch

Oct 26, 2018, 6:32:51 PM10/26/18
I've recently polished up a PR to automatically sorts all of our imports via crlfmt. Imports are sorted into two blocks, one for stdlib imports and one for all other imports. Here's an example:

import (
gosql "database/sql"

// Comments are still allowed here.

// cgo is unaffected by sorting
import "C"

If you're opposed to this, or if you have general feedback/criticism, please chime in on the PR

Please note that the latest version of goimports does exactly this sorting by default, so biting the bullet and enforcing this style now will actually prevent spurious diffs for the next several months as folks upgrade to the new goimports. Plus, if you've configured your editor to crlfmt on save using the vendored copy of crlfmt, you won't even notice this change; you'll simply get the new formatting smarts as soon as they land.


Jordan Lewis

Nov 12, 2018, 5:18:44 PM11/12/18
to Nikhil Benesch,
LGTM- let's do this! To a glorious future where nobody ever has to worry about import sorting.

Nikhil, thanks for your effort to make this happen.


You received this message because you are subscribed to the Google Groups "CockroachDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit
Reply all
Reply to author
0 new messages