format

package
v0.0.0-...-a8a9ef0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package format provides unified Go formatting in a single pass. It combines: import fixing, line shortening, and gofumpt-style rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter performs unified Go formatting.

func New

func New(opts Options) *Formatter

New creates a new formatter.

func (*Formatter) Format

func (f *Formatter) Format(filename string, src []byte) ([]byte, error)

Format formats source in a single pass.

type Options

type Options struct {
	// LineLength is the target maximum line length (default: 100)
	LineLength int

	// TabWidth is the width of a tab (default: 4)
	TabWidth int

	// GoVersion for version-specific rules (e.g., "go1.24")
	GoVersion string

	// ModulePath for import grouping
	ModulePath string

	// LocalPrefixes for local import grouping
	LocalPrefixes []string

	// ExtraRules enables stricter gofumpt rules
	ExtraRules bool

	// SkipTypeInfo disables type loading (faster but less accurate import detection)
	SkipTypeInfo bool
}

Options configures the formatter.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns sensible defaults.

Jump to

Keyboard shortcuts

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