Skip to Content
marmot
DiagnosticsError codes
example $ marmot build .
error[M0004]: declared and not used: count
 --> ./main.go:4:2
  |
4 |     count := len(xs) // never read
  |     ^^^^^ declared here but never used
  |
help: assign the value to `_`
  |
4 -     count := len(xs) // never read
4 +     _ = len(xs) // never read
  |

error[M0002]: undefined: xs
 --> ./main.go:4:15
  |
4 |     count := len(xs) // never read
  |                  ^^ not declared in this scope

error: build failed with 2 errors
1 error can be fixed automatically: run `marmot fix`
for more about an error, run `marmot explain M0002`
The program that produced it
package main

func main() {
	count := len(xs) // never read
}

Assigning to a variable does not count as a use.

The mistake and the fix

The mistake
count := len(xs) // never read
Fixed
// remove it, or use it:
count := len(xs) 
fmt.Println(count) 

The fix

Use the variable, remove it, or assign the value to _.

See also all error codes and marmot explain.

On this page

Was this page helpful?

Report an issueOpen issues