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

Go by GoLand Help

Inspections

This reference lists the Go inspections included with Go by GoLand. The tables show their names, IDs, descriptions, and default diagnostic severities in VS Code.

An inspection ID identifies a check.

The checks that run depend on your inspection profile, Go version, and code. Syntax errors, unresolved references, and type errors are also reported by the language server.

Declaration redundancy

Inspection

Description

Default severity

Bool condition

GoBoolExpressions

Reports parts of boolean expressions that are always true, always false, or redundant.

Warning

Empty declaration

GoEmptyDeclaration

Reports empty declarations that have no effect on the program.

Hint

Empty slice declared using a literal

GoPreferNilSlice

Reports slices initialized with an empty literal instead of nil.

Warning

Redundant blank argument in range

GoRedundantBlankArgInRange

Reports blank identifiers that you can omit from range loops, such as for i, _ := range values.

Hint

Redundant comma

GoRedundantComma

Reports optional trailing commas in argument lists and composite literals.

Hint

Redundant import alias

GoRedundantImportAlias

Reports import aliases that duplicate the imported package name and can be omitted.

Hint

Redundant second index in slices

GoRedundantSecondIndexInSlices

Reports an explicit upper bound in a slice expression when you can omit that bound.

Hint

Redundant semicolon

GoRedundantSemicolon

Reports semicolons that you can omit under Go syntax rules.

Hint

Redundant type conversion

GoRedundantConversion

Reports type conversions that you can omit.

Warning or Hint

Redundant types in composite literals

GoRedundantTypeDeclInCompositeLit

Reports explicit types in nested composite literals when the surrounding literal already supplies the type.

Hint

Self assignment

GoSelfAssignment

Reports assignments of a value to itself. These assignments have no effect.

Warning

Type can be omitted

GoVarAndConstTypeMayBeOmitted

Reports explicit types in variable and constant declarations when the compiler can infer those types.

Hint

Unused constant

GoUnusedConst

Reports constants that are declared but never used.

Hint

Unused exported function

GoUnusedExportedFunction

Reports exported functions with no usages.

Hint

Unused exported type

GoUnusedExportedType

Reports unused exported types in the main package and in tests.

Hint

Unused function

GoUnusedFunction

Reports unexported functions with no usages.

Hint

Unused global variable

GoUnusedGlobalVariable

Reports global variables that are declared but never used.

Hint

Unused parameter

GoUnusedParameter

Reports function parameters that the function body does not use.

Hint

Unused type

GoUnusedType

Reports types that are declared but never used.

Hint

Unused type parameter

GoUnusedTypeParameter

Reports type parameters that are declared but never used.

Hint

Code style

Inspection

Description

Default severity

Comment has no leading space

GoCommentLeadingSpace

Reports comments without a space after the comment marker when your code style settings require one.

Warning

Comment of exported element starts with the incorrect name

GoCommentStart

Reports documentation comments that do not start with the name of the exported declaration they describe.

Warning

Convert string literals

GoConvertStringLiterals

Reports double-quoted string literals that can be converted to raw strings, and raw strings that can be converted to double-quoted strings.

No diagnostic by default

Error string should not be capitalized or end with punctuation

GoErrorStringFormat

Reports error strings that start with a capital letter or end with punctuation.

Warning

Exported element should have a comment

GoExportedElementShouldHaveComment

Reports exported declarations that have no documentation comment.

No diagnostic by default

Exported element should have its own declaration

GoExportedOwnDeclaration

Reports exported variables and constants that share a comma-separated declaration with other names.

Warning

Name starts with a package name

GoNameStartsWithPackageName

Reports exported names that repeat the package name as a prefix. This check excludes the main package.

Warning

Receiver has a generic name

GoReceiverNames

Reports generic receiver names such as self, or inconsistent receiver names on methods of the same type.

Warning

Redundant 'else' in 'if'

GoRedundantElseInIf

Reports redundant else clauses after an if branch that ends with return.

Warning

Redundant 'true' in for loop condition

GoRedundantTrueInForCondition

Reports an explicit true condition in a for loop. A for loop with no condition already runs indefinitely.

Warning

Struct initialization without field names

GoStructInitializationWithoutFieldNames

Reports struct literals that specify values without field names. By default, this check applies to types defined in another package.

Warning

Type parameter is declared in lowercase

GoTypeParameterInLowerCase

Reports type parameter names that contain lowercase letters.

No diagnostic by default

Unit-specific suffix for 'time.Duration'

GoUnitSpecificDurationSuffix

Reports time unit suffixes in names of time.Duration variables and constants. These suffixes can suggest the wrong unit for a duration.

Warning

Unsorted imports

GoUnsortedImport

Reports imports whose order does not follow the gofmt sorting rules.

Warning

Usage of Snake_Case

GoSnakeCaseUsage

Reports variable, constant, and function names that use snake case instead of the mixed capitals convention used in Go.

Warning

Probable bugs

Inspection

Description

Default severity

'context.CancelFunc' is not called

GoVetLostCancel

Reports execution paths that omit a call to the cancel function returned by context.WithCancel, context.WithDeadline, or context.WithTimeout.

Warning

'FailNow' in a non-test goroutine

GoVetFailNowInNotTestGoroutine

Reports calls to testing.T.FailNow and similar methods from a goroutine other than the one running the test or benchmark.

Warning

'Unmarshal' is called with the incorrect argument

GoVetUnmarshal

Reports json.Unmarshal and similar calls whose result argument is neither a pointer nor an interface. Such calls fail.

Warning

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

GoDeferGo

Reports go and defer statements that call panic() or recover() directly.

Warning

Direct comparison of errors

GoDirectComparisonOfErrors

Reports direct comparisons between error values that can fail for wrapped errors. The errors.Is function also checks errors in the wrapping chain.

Warning

Division by zero

GoDivisionByZero

Reports division by zero.

Warning

Exceeded shift expression

GoShift

Reports shift counts that equal or exceed the bit width of the integer operand.

Warning

Imported package name as a name identifier

GoImportUsedAsName

Reports variable, parameter, and function declarations whose names hide an imported package name.

Warning

Impossible interface type assertion

GoVetImpossibleInterfaceToInterfaceAssertion

Reports interface type assertions that cannot succeed because the interfaces have methods with the same name but different signatures.

Warning

Incorrect 'strings.Replace' count argument

GoStringsReplaceCount

Reports strings.Replace calls with a replacement count of 0. These calls perform no replacements.

Warning

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

GoPrintFunctions

Reports incorrect arguments and format strings in fmt.Printf, fmt.Println, and similar printing functions.

Warning

Incorrect usage of the 'errors.As' function

GoErrorsAs

Reports errors.As calls with an invalid second argument. The argument needs to point to an interface or a type that implements error.

Warning

Incorrect usage of the 'sync/atomic' package

GoVetAtomic

Reports assignments such as x = atomic.AddUint64(&x, 1). The extra assignment makes the operation non-atomic.

Warning

Integer to string type conversion

GoVetIntToStringConversion

Reports conversions from an integer to a string, except for byte and rune values. These conversions produce a Unicode character instead of decimal digits.

Warning

Invalid conversions of 'uintptr' to 'unsafe.Pointer'

GoVetUnsafePointer

Reports unsafe conversions from uintptr to unsafe.Pointer that can hide pointers from the garbage collector.

Warning

Irregular usage of 'iota'

GoIrregularIota

Reports repeated iota expressions separated by implicit constant declarations. The repeated expression can be omitted.

Warning

Leading whitespace in directive comment

GoLeadingWhitespaceInDirectiveComment

Reports whitespace between // and a Go directive. This whitespace prevents Go from recognizing the directive.

Warning

Locks mistakenly passed by value

GoVetCopyLock

Reports copies of values that contain locks, such as sync.Mutex or sync.WaitGroup. Copying these values can break synchronization.

Warning

Loop variables captured by the func literal

GoLoopClosure

Reports references to loop variables in function literals used by go or defer. Delayed execution can observe an unexpected variable value.

Warning

Malformed build tag

GoBuildTag

Reports build tags with invalid syntax or placement. The Go tool can ignore malformed tags or select the wrong files.

Warning or Information

Malformed struct tag

GoVetStructTag

Reports malformed struct tags and tags on unexported fields.

Warning

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

GoSwitchMissingCasesForIotaConsts

Reports switch statements that omit values from a constant declaration that uses iota.

Warning

Mixed value and pointer receivers

GoMixedReceiverTypes

Reports types whose methods use a mixture of value receivers and pointer receivers.

Warning

Nilness analyzer

GoNilness

Reports problems caused by values that can be nil, including unsafe dereferences, slice indexing, and comparisons whose result is already known.

Disabled by default

Non-standard signature for well-known function names

GoStandardMethods

Reports methods whose names match standard library interface methods but whose signatures differ. A mismatched signature can prevent the type from satisfying the interface.

Warning

Reserved word used as name

GoReservedWordUsedAsName

Reports declarations whose names hide a built-in identifier, such as byte or string.

Warning

Shadowing variable

GoShadowedVar

Reports variable declarations that hide a variable with the same name in an outer scope.

Hint

The 'go:debug' directive is ignored in Go versions earlier than 1.21

GoDebugMinGoSdkVersion

Reports go:debug directives when the selected Go SDK is earlier than Go 1.21.

Warning

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

GoDebugDirective

Reports go:debug directives after the package clause or in unsupported packages. Supported packages are main and packages whose names end in _test.

Warning

Type assertion on errors fails on wrapped errors

GoTypeAssertionOnErrors

Reports type assertions and type switches on errors that can fail for wrapped errors. The errors.As function also examines the wrapping chain.

Warning

Unhandled error

GoUnhandledErrorResult

Reports calls to functions or methods whose returned error value is ignored.

Warning

Unused function or method call result

GoUnusedCallResult

Reports ignored results from functions and methods whose purpose is to return a useful value.

Warning

Control flow

Inspection

Description

Default severity

'defer' in the loop

GoDeferInLoop

Reports defer statements inside loops. Deferred calls run when the surrounding function returns, which can delay resource cleanup.

Warning

Assignment to a receiver

GoAssignmentToReceiver

Reports assignments to the receiver variable inside a method. The assignment affects only the receiver variable inside that method.

Warning

Infinite 'for' loop

GoInfiniteFor

Reports empty infinite for loops, which keep a processor busy without doing useful work.

Warning

Unreachable code

GoUnreachableCode

Reports code that no execution path can reach.

Warning

Data flow analysis

Data flow analysis follows values through your code to find constant conditions, possible nil dereferences, unchecked errors, and resource leaks.

The interprocedural check also follows values across function calls.

Inspection

Description

Default severity

Constant condition

GoDfaConstantCondition

Reports conditions that always evaluate to true or false based on the values that reach them.

Warning

Error may be not nil

GoDfaErrorMayBeNotNil

Reports uses of results that can be nil or invalid when their associated error has not been checked.

Warning

Interprocedural potential nil dereference

GoMaybeNil

Reports potential nil dereferences by following values across function calls, including calls between packages.

Warning

Potential nil dereference

GoDfaNilDereference

Reports dereferences of pointers that can be nil.

Warning or Information

Potential resource leak

GoResourceLeak

Reports resources that can remain unclosed, such as files, SQL rows, HTTP response bodies, and other values that implement io.Closer.

Warning

General

Inspection

Description

Default severity

Cyclic imports

GoCyclicImports

Reports cycles in package imports, where a chain of imports leads back to the same package.

Warning

Deprecated element

GoDeprecation

Reports uses of deprecated declarations.

Warning

Detect usages of runtime.SetFinalizer

GoDetectSetFinalizerUsages

Reports calls to runtime.SetFinalizer, which registers a callback for garbage collection of an object.

Warning

Fuzzing is supported starting with Go 1.18

GoFuzzingSupport

Reports fuzz tests when the selected Go SDK is earlier than Go 1.18.

Warning

Malformed test function name

GoTestName

Reports test, benchmark, and example function names that do not follow the naming rules of the testing package.

Warning

Missing trailing comma before a newline in a composite literal

GoMissingTrailingComma

Reports missing trailing commas before a newline in composite literals, function call arguments, and function parameter lists.

Warning

Redundant parentheses

GoRedundantParens

Reports unnecessary parentheses in expressions and types.

Warning

Struct field alignment

GoStructLayout

Reports structs whose memory usage can be reduced by reordering fields to decrease padding between them.

Disabled by default

Unexported return type of the exported function

GoExportedFuncWithUnexportedType

Reports exported functions with unexported return types. These types can make the public API harder to use and document.

Warning

Unnecessarily exported identifier

GoUnnecessarilyExportedIdentifiers

Reports exported identifiers that are used only within the package that defines them.

Disabled by default

Usage of 'interface{}' as a type

GoInterfaceToAny

Reports empty interfaces used as types or type constraints when Go 1.18 or later is available. The any alias denotes the same type.

No diagnostic by default

Usage of context.TODO()

GoContextTodo

Reports uses of context.TODO(), which marks a temporary placeholder for a context that has not yet been chosen.

Disabled by default

17 November 2026