Golang import grouping by package
The latest version of goimports
support -local
flag. Quoting this commit message:
For example, running goimports -local example.com/
might produce
import (
"database/sql"
"io"
"strconv"
"golang.org/x/net/context"
"example.com/foo/bar"
"example.com/foo/baz"
)
If one is using GoLand, it's possible to adjust sorting in the settings:
Note “Group stdimports” and “Move all stdimports in a single group” checkboxes.