- grouping/ordering import, if blank line exists before/after paths.
- set directories or files as arguments of the command.
- if you set the prefix to -local option, the packages which beginning with that prefix put after 3rd-party packages.
- use -w option to override original files.
GLOBAL OPTIONS:
--local value, -l value specify imports prefix beginning with this string after 3rd-party packages. especially your own organization name. comma-separated list
--write, -w write result source to original file instead od stdout (default: false)
example command.
$ grouper -local "github.com/tommy-sho" path_to_file.go
- before
package main
import(
"bytes"
"errors"
"github.com/tommy-sho/grouper"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/imports"
)
...
- after grouper run...
package main
import (
"bytes"
"errors"
"fmt"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/imports"
"github.com/tommy-sho/grouper"
)
- in case of goimports...
package main
import(
"bytes"
"errors"
"github.com/tommy-sho/grouper"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/imports"
)
with go
command.
$ go install github.com/tommy-sho/grouper
MIT
tommy-sho