Skip to Content
marmot
DiagnosticsError codes
example $ marmot build .
error[M0002]: undefined: fmt.Printn
 --> ./main.go:9:6
  |
9 |     fmt.Printn("hi")
  |         ^^^^^^ not declared by package `fmt`
  |
help: use `fmt.Println` (check it)
  |
9 -     fmt.Printn("hi")
9 +     fmt.Println("hi")
  |

error[M0004]: declared and not used: n
  --> ./main.go:10:2
   |
10 |     n := strings.Count(s, "a") // strings not imported
   |     ^ declared here but never used
   |
help: assign the value to `_`
   |
10 -     n := strings.Count(s, "a") // strings not imported
10 +     _ = strings.Count(s, "a") // strings not imported
   |

error[M0002]: undefined: s
  --> ./main.go:10:21
   |
10 |     n := strings.Count(s, "a") // strings not imported
   |                        ^ not declared in this scope
   |
help: use `n` (check it)
   |
10 -     n := strings.Count(s, "a") // strings not imported
10 +     n := strings.Count(n, "a") // strings not imported
   |

error: build failed with 3 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

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Printn("hi")
	n := strings.Count(s, "a") // strings not imported
}

It may be misspelled, declared in a file excluded by build tags, or belong to a package that is not imported.

The mistake and the fix

The mistake
fmt.Printn("hi")
n := strings.Count(s, "a") // strings not imported
Fixed
import "strings"

fmt.Println("hi") 
n := strings.Count(s, "a") 

The fix

Fix the spelling, or import the package that declares it.

See also all error codes and marmot explain.

On this page

Was this page helpful?

Report an issueOpen issues