Skip to content

simple golang formatting tool that makes imports grouped

License

Notifications You must be signed in to change notification settings

tommy-sho/grouper

Repository files navigation

GitHub Releases
license
build status

Features

  • grouping/ordering import, if blank line exists before/after paths.

Usage

  • 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

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"
)

Install

with go command.

$  go install github.com/tommy-sho/grouper

License

MIT

Author

tommy-sho

About

simple golang formatting tool that makes imports grouped

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages