You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
sudo pacman -Syu 23bead0fe7 chore: golds add dark theme 1 week ago
.github chore: bump go 1.20 github action 4 weeks ago
cmd/gofimports feat: improve perf by use astFile for dstFile 2 months ago
internal chore: fix lint 4 weeks ago
.gitignore feat: add profiler 2 months ago
.golangci.yml chore: fix lint 4 weeks ago
.goreleaser.yml chore: add github action, Makefile 4 months ago
CHANGELOG.md chore(changelog): generate v0.0.8 4 weeks ago
LICENSE chore: add MIT license 4 months ago
Makefile chore: golds add dark theme 1 week ago
README.md chore: clarify company prefix guide 2 months ago
go.mod chore(deps): bump golang.org/x/tools from 0.6.0 to 0.7.0 2 weeks ago
go.sum chore(deps): bump golang.org/x/tools from 0.6.0 to 0.7.0 2 weeks ago

README.md

gofimports

Go Go Reference

Group Go imports with my opinionated preferences.

First is standard. Then third party, then company if exist. The last is local.

Also main selling point of this tool is to handle imports only. So please run gofumpt or gofmt to format you files after running this tool.

Install

With Go version >= 1.16:

go install github.com/haunt98/gofimports/cmd/gofimports@latest

Usage

# Format ./internal with:
# - print impacted file (-l),
# - write to file (-w),
# - print diff (-d)
# - company prefix, split using comma (,)
gofimports -l -w -d --company github.com/make-go-great,github.com/haunt98 ./internal

Example result:

import (
    "fmt"

    "github.com/urfave/cli/v2"
    "github.com/pkg/diff"

    "github.com/make-go-great/color-go"

    "github.com/haunt98/gofimports/internal/imports"
)

Roadmap

  • Diff with color
  • Add profiling
  • Improve performance

Thanks