Errors and Warnings

When you write code, GoLand will sometimes underline things to warn you.

GoLand warning


What the underlines mean

GoLand sends color-coded messages to help you.

  • Red underline (Error): “This cannot run.” The syntax is wrong or the code does not make sense. Your program will not run until you fix it.
  • Yellow underline (Warning): “It runs, but there is a better way.” You did not follow Go’s rules or recommended style.

Go’s special rule

Go is famous for clean code, so it has a unique rule.

“If you declare it and do not use it, that is not allowed!”

If you create a variable (x := 10) and never use it, GoLand shows a red underline and raises an error. It is basically yelling, “Do not create it if you will not use it!”

GoLand unused error

This strictness is why Go code stays clean and tidy.