Import sorting

15 views
Skip to first unread message

Nikhil Benesch

unread,
Oct 26, 2018, 6:32:51 PM10/26/18
to cockro...@googlegroups.com
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 (
"context"
gosql "database/sql"
"encoding/json"
"time"

// 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.

N

Jordan Lewis

unread,
Nov 12, 2018, 5:18:44 PM11/12/18
to Nikhil Benesch, cockro...@googlegroups.com
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.

Jordan

--
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 cockroach-db...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cockroach-db/CAA-gNqKJXn0Gg2GEVdF-WZMbEPtw8UU_LtaAfSzM-Dg6uEQwgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages