gosimports

module
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2021 License: BSD-3-Clause

README

gosimports - simpler goimports

  • 🚀 Just replace goimports with gosimports !
  • ✨ Simpler than goimports
  • 💯 Interface compatible with goimports (result is not compatible, but simpler)
  • 🔨 Originally forked from golang.org/x/tools/cmd/goimports

Installation

Go 1.16 or later
go install github.com/rinchsan/gosimports/cmd/gosimports@latest
Go 1.15 or earlier
go get github.com/rinchsan/gosimports/cmd/gosimports
Homebrew
brew install rinchsan/tap/gosimports
Binary

Download binaries from GitHub Releases

Example

import (
	"bufio"

	// basic comments

	/*
		block comments
	*/

	"github.com/rinchsan/gosimports/internal/imports"

	"errors"
	gocmd "github.com/rinchsan/gosimports/internal/gocommand"
	"flag"

	"runtime"
	_ "runtime/pprof" // trailing inline comments
	"strings"

)

$ gosimports -w 👍

import (
	"bufio"
	"errors"
	"flag"
	"runtime"
	_ "runtime/pprof" // trailing inline comments
	"strings"

	gocmd "github.com/rinchsan/gosimports/internal/gocommand"
	"github.com/rinchsan/gosimports/internal/imports"
)

while goimports formatting like below 👎

import (
	"bufio"

	// basic comments

	/*
		block comments
	*/

	"github.com/rinchsan/gosimports/internal/imports"

	"errors"
	"flag"

	gocmd "github.com/rinchsan/gosimports/internal/gocommand"

	"runtime"
	_ "runtime/pprof" // trailing inline comments
	"strings"
)

License

Copyright 2013 The Go Authors. All rights reserved.

Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Directories

Path Synopsis
cmd
gosimports
Command gosimports updates your Go import lines, adding missing ones, removing unreferenced ones, and removing redundant blank lines.
Command gosimports updates your Go import lines, adding missing ones, removing unreferenced ones, and removing redundant blank lines.
internal
event/core
Package core provides support for event based telemetry.
Package core provides support for event based telemetry.
event/export/eventtest
Package eventtest supports logging events to a test.
Package eventtest supports logging events to a test.
event/export/metric
Package metric aggregates events into metrics that can be exported.
Package metric aggregates events into metrics that can be exported.
event/export/ocagent
Package ocagent adds the ability to export all telemetry to an ocagent.
Package ocagent adds the ability to export all telemetry to an ocagent.
fastwalk
Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.
Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.
gocommand
Package gocommand is a helper for calling the go command.
Package gocommand is a helper for calling the go command.
gopathwalk
Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
imports
Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
proxydir
Package proxydir provides functions for writing module data to a directory in proxy format, so that it can be used as a module proxy by setting GOPROXY="file://<dir>".
Package proxydir provides functions for writing module data to a directory in proxy format, so that it can be used as a module proxy by setting GOPROXY="file://<dir>".
testenv
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL