github.com/rhysd/gofmtrlx (go): Gofmt formats Go programs. It uses tabs for indentation and blanks for alignment. Alignment assumes that an editor is using a fixed-width font.  Without an explicit path, it processes the standard input.  Given a file, it operates on that file; given a directory, it operates on all .go files in that directory, recursively.  (Files starting with a period are ignored.) By default, gofmt prints the reformatted sources to standard output.  Usage:  The flags are:  Debugging support:  The rewrite rule specified with the -r flag must be a string of the form:  Both pattern and replacement must be valid Go expressions. In the pattern, single-character lowercase identifiers serve as wildcards matching arbitrary sub-expressions; those expressions will be substituted for the same identifiers in the replacement.  When gofmt reads from standard input, it accepts either a full Go program or a program fragment.  A program fragment must be a syntactically valid declaration list, statement list, or expression.  When formatting such a fragment, gofmt preserves leading indentation as well as leading and trailing spaces, so that individual sections of a Go program can be formatted by piping them through gofmt.  To check files for unnecessary parentheses:  To remove the parentheses:  To convert the package tree from explicit slice upper bounds to implicit ones:  When invoked with -s gofmt will make the following source transformations where possible.  This may result in changes that are incompatible with earlier versions of Go.
Keywords: formatter|golang