gofix

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

Package gofix defines an Analyzer that checks "//go:fix inline" directives. See golang.org/x/tools/internal/gofix/doc.go for details.

Analyzer gofixdirective

gofixdirective: validate uses of gofix comment directives

The gofixdirective analyzer checks "//go:fix inline" directives for correctness.

The proposal https://go.dev/issue/32816 introduces the "//go:fix" directives.

The analyzer checks for the following issues:

- A constant definition can be marked for inlining only if it refers to another named constant.

//go:fix inline
const (
	a = 1       // error
	b = iota    // error
	c = a       // OK
	d = math.Pi // OK
)

- A type definition can be marked for inlining only if it is an alias.

//go:fix inline
type (
	T int    // error
	A = int  // OK
)

- An alias whose right-hand side contains a non-literal array size cannot be marked for inlining.

const two = 2

//go:fix inline
type (
	A = []int     // OK
	B = [1]int    // OK
	C = [two]int  // error
)

Package gofix defines an analyzer that checks go:fix directives.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "gofixdirective",
	Doc:      analysisinternal.MustExtractDoc(doc, "gofixdirective"),
	URL:      "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/gofix",
	Run:      run,
	Requires: []*analysis.Analyzer{inspect.Analyzer},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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