https://github.com/indeedeng/go-groups
Command go-groups is a CLI tool to parse go import blocks, sort, and re-group the imports
https://github.com/indeedeng/go-groups
Last synced: about 1 year ago
JSON representation
Command go-groups is a CLI tool to parse go import blocks, sort, and re-group the imports
- Host: GitHub
- URL: https://github.com/indeedeng/go-groups
- Owner: indeedeng
- License: bsd-3-clause
- Created: 2019-06-25T18:36:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-23T19:52:28.000Z (about 3 years ago)
- Last Synced: 2025-05-07T23:40:07.029Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 8
- Watchers: 10
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
go-groups
=========
[](https://goreportcard.com/report/oss.indeed.com/go/go-groups)
[](https://travis-ci.org/indeedeng/go-groups)
[](https://godoc.org/oss.indeed.com/go/go-groups)
[](OSSMETADATA)
[](LICENSE)
# Project Overview
Command `go-groups` is a CLI tool to deterministically rewrite go import blocks to sort and re-group
the imports.
`go-groups` is similar to `goimports`, but in addition to sorting imports
lexigraphically, it also separates import blocks at a per-project level.
Like `goimports`, `go-groups` also runs gofmt and fixes any style/formatting
issues.
# Getting Started
The `go-groups` command can be installed by running:
```
$ go install oss.indeed.com/go/go-groups@latest
```
# Usage
```
$ go-groups -h
usage: go-groups [flags] [path ...]
-d display diffs instead of rewriting files
-f disables the automatic gofmt style fixes
-g include generated code in analysis
-l list files whose formatting differs
-v display the version of go-groups
-w write result to (source) file instead of stdout
```
# Formatting Behavior
#### With this example source file input
```
import (
"strings"
"github.com/pkg/errors"
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/csrf"
)
```
#### Running `go-groups` will produce
```
import (
"fmt"
"strings"
"github.com/gorilla/csrf"
"github.com/gorilla/mux"
"github.com/pkg/errors"
)
```
#### Typical Workflow
Run `go-groups -w ./..` to rewrite and sort import groupings for go source files in a project.
# Asking Questions
For technical questions about `go-groups`, just file an issue in the GitHub tracker.
For questions about Open Source in Indeed Engineering, send us an email at
opensource@indeed.com
# Contributing
We welcome contributions! Feel free to help make `go-groups` better.
### Process
- Open an issue and describe the desired feature / bug fix before making
changes. It's useful to get a second pair of eyes before investing development
effort.
- Make the change. If adding a new feature, remember to provide tests that
demonstrate the new feature works, including any error paths. If contributing
a bug fix, add tests that demonstrate the erroneous behavior is fixed.
- Open a pull request. Automated CI tests will run. If the tests fail, please
make changes to fix the behavior, and repeat until the tests pass.
- Once everything looks good, one of the indeedeng members will review the
PR and provide feedback.
# Maintainers
The `oss.indeed.com/go/go-groups` module is maintained by Indeed Engineering.
While we are always busy helping people get jobs, we will try to respond to
GitHub issues, pull requests, and questions within a couple of business days.
# Code of Conduct
`oss.indeed.com/go/go-groups` is governed by the [Contributer Covenant v1.4.1](CODE_OF_CONDUCT.md)
For more information please contact opensource@indeed.com.
# License
The `oss.indeed.com/go/go-groups` module is open source under the [BSD-3-Clause](LICENSE) license.