DiagnosticsError codes
M0003 no such field or method
The selector names a field or method the type does not have.
example $ marmot build . error[M0003]: b.WriteStrin undefined (type strings.Builder has no field or method WriteStrin) --> ./main.go:9:4 | 9 | b.WriteStrin("x") | ^^^^^^^^^^ `strings.Builder` has no field or method `WriteStrin` | = note: methods of `strings.Builder`: `(*Builder) Cap`, `(*Builder) Grow`, `(*Builder) Len`, `(*Builder) Reset`, `(*Builder) String`, `(*Builder) Write`, `(*Builder) WriteByte`, `(*Builder) WriteRune`, `(*Builder) WriteString` help: use `WriteString` (check it) | 9 - b.WriteStrin("x") 9 + b.WriteString("x") | error: build failed with 1 error for more about an error, run `marmot explain M0003`
The program that produced it
package main
import (
"strings"
)
func main() {
var b strings.Builder
b.WriteStrin("x")
}
For methods, check the receiver: a method with a pointer receiver is not in the method set of the value type when the value is not addressable.
The mistake and the fix
var b strings.Builder
b.WriteStrin("x")var b strings.Builder
b.WriteString("x") The fix
Use one of the fields or methods of the type.
See also all error codes and marmot explain.