Skip to Content
marmot
DiagnosticsError codes
example $ marmot build .
error[M0010]: missing return
 --> ./main.go:7:1
  |
7 | }
  | ^
  |
  = help: add a `return` at the end of the function, or `panic` if the end cannot be
          reached

error: build failed with 1 error
for more about an error, run `marmot explain M0010`
The program that produced it
package main

func sign(x int) int {
	if x < 0 {
		return -1
	}
}

func main() {}

The mistake and the fix

The mistake
func sign(x int) int {
	if x < 0 {
		return -1
	}
}
Fixed
func sign(x int) int {
	if x < 0 {
		return -1
	}
	return 1
}

The fix

Add a return at the end, or a panic for a case that cannot happen.

See also all error codes and marmot explain.

On this page

Was this page helpful?

Report an issueOpen issues