Inspectopedia 2026.2 Help

Go fix

'errors.As' can be replaced with 'errors.AsType'   New in this release

Reports calls to errors.As that can be replaced with errors.AsType.

'HasPrefix' and 'TrimPrefix' can use 'strings.CutPrefix'   New in this release

Reports code that checks a prefix with strings.HasPrefix and then removes the same prefix with strings.TrimPrefix.

'interface{}' can be replaced with 'any'   New in this release

Reports type declarations that use interface{} and can be simplified by using any.

'Len()'/'At()' loop can be replaced with iterator   New in this release

Reports index-based loops over standard library types where the loop body only accesses elements by index, such as x.At(i).

'omitempty' tag on a struct field can be changed   New in this release

Reports JSON struct tags that use ,omitempty on struct-typed fields.

'reflect.TypeOf' can be replaced with ‘reflect.TypeFor’   New in this release

Reports uses of reflect.TypeOf where the type is known at compile time, such as reflect.TypeOf(T{}) and reflect.TypeOf((*T)(nil)).Elem().

'sort.Slice' can be replaced with 'slices.Sort'   New in this release

Reports calls to sort.Slice where the comparison function only compares elements with the < operator.

'strings.Index' and slicing can use 'strings.Cut'   New in this release

Reports code that uses strings.Index to find a separator and then slices the string manually.

'strings.Split' or 'strings.Fields' loop can use a 'Seq' variant   New in this release

Reports loops that range over strings.Split or strings.Fields.

Address can be built with 'net.JoinHostPort'   New in this release

Reports addresses built with fmt.Sprintf("%s:%d", host, port) or fmt.Sprintf("%s:%s", host, port).

Apply 'atomictypes' go fix   New in this release

Reports opportunities found by go fix -json -atomictypes.

Apply 'buildtag' go fix   New in this release

Reports opportunities found by go fix -json -buildtag.

Apply 'fmtappendf' go fix   New in this release

Reports opportunities found by go fix -json -fmtappendf.

Apply 'unsafefuncs' go fix   New in this release

Reports opportunities found by go fix -json -unsafefuncs.

Backward slice loop can use 'slices.Backward'   New in this release

Reports reverse index loops over slices that can be replaced with slices.Backward.

Conditional assignment can be replaced with 'min' or 'max'   New in this release

Syntax update: replace conditional assignment with min or max Reports if statements that assign one of two values to the same variable and can be replaced with the built-in min or max function (Go 1.21 or later).

Counted loop can be replaced with range over integer   New in this release

Reports three-clause for loops of the form for i := 0; i < n; i++ that can be replaced with for i := range n (Go 1.22 or later).

Declaration marked with '//go:fix inline' can be inlined   New in this release

Reports references to functions or constants marked with //go:fix inline.

Map loop can be replaced with the 'maps' function   New in this release

Reports loops that copy a map or collect its keys or values and can be replaced with maps.Copy, maps.Keys, or maps.Values.

Nested embedded field literals can be removed   New in this release

Reports composite literals that initialize a promoted field through an embedded struct literal.

Obsolete '+build' line   New in this release

Reports // +build lines that are no longer needed because the file already contains a matching //go:build directive.

Pointer helper call can be replaced with 'new()'   New in this release

Reports calls to pointer helper functions that return the address of a parameter, such as IntPtr(x) returning &x, and can be replaced with new(...).

Redundant range variable shadowing   New in this release

Reports redundant variable shadowing inside a for range loop, such as x := x, that was previously used to capture the loop variable for a goroutine or closure.

Slice search loop can be replaced with 'slices.Contains'   New in this release

Reports loops that check whether a slice contains a value by comparing each element with ==.

String concatenation can use 'strings.Builder'   New in this release

Reports index-based loops over standard library types where the loop body only accesses elements by index, such as x.At(i).

Test context cancellation can use 't.Context()'   New in this release

Reports test code that creates a cancellable context with context.WithCancel(context.Background()) and immediately defers cancel().

WaitGroup goroutine pattern can use 'WaitGroup.Go'   New in this release

Reports the common WaitGroup pattern that uses wg.Add(1), starts a goroutine, and defers wg.Done().

Last modified: 30 June 2026