1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:54:40 -07:00

cmd/goimports: update doc, remove old gofmt flags

Don't say the word "fork" (not accurate), and remove the
tab/comment flags that were removed from gofmt.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/61410052
This commit is contained in:
Brad Fitzpatrick 2014-02-12 08:35:02 -08:00
parent d10dca34ca
commit 05bc285da4
2 changed files with 9 additions and 10 deletions

View File

@ -5,13 +5,12 @@ adding missing ones and removing unreferenced ones.
$ go get code.google.com/p/go.tools/cmd/goimports
It's a fork of gofmt, and will also format your code, so it can be
used as a replacement for your gofmt-on-save hook in your editor of
choice.
It's a drop-in replacement for your editor's gofmt-on-save hook.
It has the the same command-line interface as gofmt and formats
your code in the same way.
For emacs, make sure you have the latest (Go 1.2) go-mode.el:
For emacs, make sure you have the latest (Go 1.2+) go-mode.el:
https://go.googlecode.com/hg/misc/emacs/go-mode.el
Then in your .emacs file:
(setq gofmt-command "goimports")
(add-to-list 'load-path "/home/you/goroot/misc/emacs/")
@ -19,7 +18,6 @@ Then in your .emacs file:
(add-hook 'before-save-hook 'gofmt-before-save)
For vim, set "gofmt_command" to "goimports":
https://code.google.com/p/go/source/detail?r=39c724dd7f252
https://code.google.com/p/go/source/browse#hg%2Fmisc%2Fvim
etc

View File

@ -26,15 +26,16 @@ var (
write = flag.Bool("w", false, "write result to (source) file instead of stdout")
doDiff = flag.Bool("d", false, "display diffs instead of rewriting files")
options = &imports.Options{}
options = &imports.Options{
TabWidth: 8,
TabIndent: true,
Comments: true,
}
exitCode = 0
)
func init() {
flag.BoolVar(&options.AllErrors, "e", false, "report all errors (not just the first 10 on different lines)")
flag.BoolVar(&options.Comments, "comments", true, "print comments")
flag.IntVar(&options.TabWidth, "tabwidth", 8, "tab width")
flag.BoolVar(&options.TabIndent, "tabs", true, "indent with tabs")
}
func report(err error) {