format

package
v0.0.0-...-5a67fa7 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package format exposes gofumpt's formatting in an API similar to go/format. In general, the APIs are only guaranteed to work well when the input source is in canonical gofmt format.

The goVersion parameter taken by some of the functions should correspond to the Go language version a piece of code is written in. The version is used to decide whether to apply formatting rules which require new language features. When inside a Go module, goVersion should be the result of:

go list -m -f {{.GoVersion}}

goVersion is treated as a semantic version, which might start with a "v" prefix. Like Go versions, it might also be incomplete; "1.14" is equivalent to "1.14.0". An empty goVersion is equivalent to "v99", to use all available language features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(fset *token.FileSet, file *ast.File, goVersion string)

File modifies a file and fset in place to follow gofumpt's format. The changes might include manipulating adding or removing newlines in fset, modifying the position of nodes, or modifying literal values.

func Source

func Source(src []byte, goVersion string) ([]byte, error)

Source formats src in gofumpt's format, assuming that src holds a valid Go source file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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