llms.txt: machine-readable documentation index. Markdown version of this page is also available.

Go by GoLand Help

Quick-fixes

This reference lists quick-fixes for problems that the Go inspections in Go by GoLand report.

The available actions depend on your code, Go version, and enabled inspections. Names and expressions in italics depend on your code.

For instructions, refer to Apply a quick-fix. For inspection descriptions and default settings, refer to Inspections.

Unused declarations

Quick-fix

What it does

Related inspections

Delete constant 'name'

Deletes an unused constant.

Unused constant

Delete function

Deletes an unused function.

Unused function

Unused exported function

Delete type 'name'

Deletes an unused type declaration.

Unused type

Unused exported type

Delete variable 'name'

Deletes an unused variable.

Unused global variable

Rename to _

Replaces an unused name with the blank identifier _.

Unused global variable

Unused function

Unused exported function

Unused parameter

Unused type parameter

Redundant code

Quick-fix

What it does

Related inspections

Delete blank argument

Removes an unnecessary blank identifier from a range loop.

Redundant blank argument in range

Delete conversion

Removes a redundant type conversion.

Redundant type conversion

Delete conversion (might change semantics)

Removes a type conversion that can affect the result of the expression.

Redundant type conversion

Delete empty declaration

Removes an empty var, const, type, or import declaration.

Empty declaration

Delete import alias

Removes an import alias that duplicates the package name.

Redundant import alias

Delete redundant index

Removes an unnecessary upper bound, such as len(values) in values[:len(values)].

Redundant second index in slices

Delete redundant type

Removes a type and an address operator from a composite literal where Go can infer them.

Redundant types in composite literals

Delete type

Removes a type that Go can infer from a declaration. In an impossible type switch case, removes the type or the whole case.

Type can be omitted

Impossible interface type assertion

Redundant 'else' branch

Removes an unnecessary else after an if branch that exits.

Redundant 'else' in 'if'

Remove redundant 'comma'

Removes an optional trailing comma.

Redundant comma

Remove redundant 'semicolon'

Removes an unnecessary semicolon.

Redundant semicolon

Remove self assignment

Removes an assignment of a value to itself.

Self assignment

Unwrap parentheses

Removes unnecessary parentheses around an expression.

Redundant parentheses

Expressions and control flow

Quick-fix

What it does

Related inspections

Simplify expression

Simplifies a boolean expression, such as value && true.

Bool condition

Simplify 'expression' to 'value'

Replaces an expression with its constant boolean value, such as !false with true.

Bool condition

Simplify to 'expression'

Removes a redundant boolean literal, such as false in value || false.

Bool condition

Remove 'for' loop

Removes a for loop whose condition is always false.

Bool condition

Remove redundant condition

Removes a loop condition that is always true.

Bool condition

Redundant 'true' in for loop condition

Replace with 'select'

Replaces an empty infinite for loop with select {}, which blocks without consuming CPU time in a loop.

Infinite 'for' loop

Create 'default' clause

Adds a default clause to a switch that does not cover all constants declared with iota.

Missing 'case' statements for 'iota' consts in 'switch'

Create missing iota clauses

Adds case clauses for missing constants declared with iota.

Missing 'case' statements for 'iota' consts in 'switch'

Create intermediate variable

Adds a local copy of a loop variable before a function literal captures it.

Loop variables captured by the func literal

Errors and function calls

Quick-fix

What it does

Related inspections

Handle error

Assigns the returned error to a variable and adds an if err != nil block.

Unhandled error

Ignore explicitly

Assigns an unused return value to the blank identifier _.

Unhandled error

Unused function or method call result

Wrap error handling in a closure

Wraps a deferred call or a goroutine call in a function literal and adds an error check inside it.

Unhandled error

Fix error string format

Changes an error string to start with a lowercase letter and removes punctuation at the end.

Error string should not be capitalized or end with punctuation

Change 'function' to formatting function

Replaces a print function with its formatting variant, such as fmt.Print with fmt.Printf.

Incorrect usage of 'fmt.Printf' and 'fmt.Println' functions

Convert integer to string using conversion call

Uses a strconv function to produce decimal digits, such as strconv.Itoa(value). The function depends on the integer type.

Integer to string type conversion

Convert integer to rune

Converts the integer argument to rune to make the Unicode code point conversion explicit.

Integer to string type conversion

Add pointer

Changes a parameter or receiver type to a pointer so it does not copy a lock.

Locks mistakenly passed by value

Prepend '&'

Passes the address of an argument to errors.As or an unmarshaling function.

Incorrect usage of the 'errors.As' function

'Unmarshal' is called with the incorrect argument

Replace with correct defer construct

Wraps recover() in a deferred function so it can recover from a panic.

Defer/go statement calls 'recover' or 'panic' directly

Replace with 'method' and 'return'

Replaces FailNow, Fatal, or Fatalf with Fail, Error, or Errorf and adds return to the goroutine.

'FailNow' in a non-test goroutine

Names and code style

Quick-fix

What it does

Related inspections

Rename to 'name'

Removes the package name prefix from an identifier and updates its references.

Name starts with a package name

Drop unit-specific suffix 'suffix'

Removes a unit suffix, such as Secs, from a time.Duration name and updates its references.

Unit-specific suffix for 'time.Duration'

Extract to own declaration

Moves an exported variable or constant into a separate declaration from unexported names.

Exported element should have its own declaration

Add 'prefix' prefix to comment

Adds the declaration name or Package name at the start of a documentation comment.

Comment of exported element starts with the incorrect name

Add whitespace

Adds a space after the comment marker.

Comment has no leading space

Sort imports

Sorts imports according to the Go code style settings.

Unsorted imports

Add comma

Adds a trailing comma before a newline in a literal, parameter list, or type argument list.

Missing trailing comma before a newline in a composite literal

Build tags and directives

Quick-fix

What it does

Related inspections

Add missing newline

Adds a blank line between a // +build comment and the package clause.

Malformed build tag

Place build tag before package

Moves a // +build comment before the package clause.

Malformed build tag

Convert //+build comments to //go:build directive

Converts legacy build comments into a //go:build directive.

Malformed build tag

Update //+build comments

Updates legacy build comments to match the //go:build condition.

Malformed build tag

Place go:debug before package

Moves a //go:debug directive before the package clause.

The 'go:debug' directive must be placed before the package clause

Remove leading whitespace before Go directive

Removes spaces between // and a Go directive.

Leading whitespace in directive comment

Structs and slices

Quick-fix

What it does

Related inspections

Add keys and delete zero values

Adds field names to a struct literal and removes fields set to their zero values.

Struct initialization without field names

Update struct 'name' layout

Reorders fields to reduce padding. It stops if any struct literal sets values without field names.

Struct field alignment

Replace with nil (changes semantics)

Replaces an empty slice literal with nil. This changes the slice from non-nil to nil.

Empty slice declared using a literal

Replace with nil slice declaration (changes semantics)

Replaces an empty slice initialization with a var declaration of a nil slice.

Empty slice declared using a literal

These actions help you inspect a problem. They move the caret without changing your code.

Quick-fix

What it does

Related inspections

17 November 2026