Skip to Content
marmot
DiagnosticsError codes
example $ marmot build .
error[M0024]: name indexFunc not exported by package strings
  --> ./main.go:10:15
   |
10 |     i := strings.indexFunc(s, unicode.IsSpace)
   |                  ^^^^^^^^^ unexported: only package `strings` can use it
   |
help: use `strings.IndexFunc` (check it)
   |
10 -     i := strings.indexFunc(s, unicode.IsSpace)
10 +     i := strings.IndexFunc(s, unicode.IsSpace)
   |

error[M0009]: not enough arguments in call to strings.indexFunc
  --> ./main.go:10:43
   |
10 |     i := strings.indexFunc(s, unicode.IsSpace)
   |                                              ^ missing arguments
   |
   = note: expected `(string, func(rune) bool, bool)`, found
           `(string, func(r rune) bool)`
   = note: `strings.indexFunc` is declared as
           `func indexFunc(s string, f func(rune) bool, truth bool) int`

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

import (
	"strings"
	"unicode"
)

func main() {
	s := "hello, marmot"
	i := strings.indexFunc(s, unicode.IsSpace)
	_ = i
}

The mistake and the fix

The mistake
i := strings.indexFunc(s, unicode.IsSpace)
Fixed
i := strings.IndexFunc(s, unicode.IsSpace) 

The fix

Use the exported name (upper case first letter).

See also all error codes and marmot explain.

On this page

Was this page helpful?

Report an issueOpen issues