ab

command
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Gofmt formats Go programsssss. 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:

gofmt [flags] [path ...]

The flags are:

-d
    Do not print reformatted sources to standard output.
    If a file's formatting is different than gofmt's, print diffs
    to standard output.
-w
    Do not print reformatted sources to standard output.
    If a file's formatting is different from gofmt's, overwrite it
    with gofmt's version. If an error occurred during overwriting,
    the original file is restored from an automatic backup.

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.

Jump to

Keyboard shortcuts

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