Movatterモバイル変換


[0]ホーム

URL:


goimports

command
v0.38.0Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License:BSD-3-ClauseImports:18Imported by:33

Details

Repository

cs.opensource.google/go/x/tools

Links

Documentation

Overview

Command goimports updates your Go import lines,adding missing ones and removing unreferenced ones.

$ go install golang.org/x/tools/cmd/goimports@latest

In addition to fixing imports, goimports also formatsyour code in the same style as gofmt so it can be usedas a replacement for your editor's gofmt-on-save hook.

For emacs, make sure you have the latest go-mode.el:

https://github.com/dominikh/go-mode.el

Then in your .emacs file:

(setq gofmt-command "goimports")(add-hook 'before-save-hook 'gofmt-before-save)

For vim, set "gofmt_command" to "goimports":

https://golang.org/change/39c724dd7f252https://golang.org/wiki/IDEsAndTextEditorPluginsetc

For GoSublime, follow the steps described here:

http://michaelwhatcott.com/gosublime-goimports/

For other editors, you probably know what to do.

To exclude directories in your $GOPATH from being scanned for Gofiles, goimports respects a configuration file at$GOPATH/src/.goimportsignore which may contain blank lines, commentlines (beginning with '#'), or lines naming a directory relative tothe configuration file to ignore when scanning. No globbing or regexpatterns are allowed. Use the "-v" verbose flag to verify it'sworking and see what goimports is doing.

File bugs or feature requests at:

https://golang.org/issues/new?title=x/tools/cmd/goimports:+

Happy hacking!

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp