golang/go · warning
no method or field %s.%s in package%s
Error message
no method or field %s.%s in package%s
What it means
Returned by go doc's failMessage when the lookup included a method/field selector (Symbol.Method) and neither was found on the type. Companion to the 'no symbol' case; it names symbol, method, and the package path(s) searched.
Source
Thrown at src/cmd/go/internal/doc/doc.go:358
}
// failMessage creates a nicely formatted error message when there is no result to show.
func failMessage(paths []string, symbol, method string) error {
var b bytes.Buffer
if len(paths) > 1 {
b.WriteString("s")
}
b.WriteString(" ")
for i, path := range paths {
if i > 0 {
b.WriteString(", ")
}
b.WriteString(path)
}
if method == "" {
return fmt.Errorf("no symbol %s in package%s", symbol, &b)
}
return fmt.Errorf("no method or field %s.%s in package%s", symbol, method, &b)
}
// parseArgs analyzes the arguments (if any) and returns the package
// it represents, the part of the argument the user used to identify
// the path (or "" if it's the current package) and the symbol
// (possibly with a .method) within that package.
// parseSymbol is used to analyze the symbol itself.
// The boolean final argument reports whether it is possible that
// there may be more directories worth looking at. It will only
// be true if the package path is a partial match for some directory
// and there may be more matches. For example, if the argument
// is rand.Float64, we must scan both crypto/rand and math/rand
// to find the symbol, and the first call will return crypto/rand, true.
func parseArgs(ctx context.Context, flagSet *flag.FlagSet, args []string) (pkg *load.Package, path, symbol string, more bool) {
wd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}View on GitHub (pinned to b6b368adc5)
Solutions
- Inspect the type with `go doc <pkg>.<Type>` to list its actual methods/fields.
- Verify receiver kind (value vs pointer) — pointer-receiver methods are not in the value's method set.
- Check the version of the dependency providing the type.
- Correct typos in the method name.
Example fix
# before $ go doc os.File.NotAMethod # -> no method or field File.NotAMethod in package os # after $ go doc os.File $ go doc os.File.Read
Defensive patterns
Strategy: validation
Validate before calling
// enumerate methods of the type before assuming one exists
if out, _ := exec.Command("go", "doc", pkg+"."+typ).Output(); !bytes.Contains(out, []byte(method)) {
return fmt.Errorf("method %s missing on %s; see `go doc %s.%s`", method, typ, pkg, typ)
} Prevention
- Inspect the type with `go doc <pkg>.<Type>` to list methods.
- Account for value vs pointer receiver differences.
- Verify the dependency version exposes the method.
When it happens
Trigger: Running `go doc <pkg>.<Type>.<Method>` where <Method> is not a method or field of <Type> in the resolved package(s).
Common situations: Method renamed/removed in a newer version; method only available behind build tags or a different type; typo in the method name; confusing a value method with a pointer-receiver-only method.
Related errors
- no symbol %s in package%s
- no such package: %s
- unexpected stdout: %q
- cannot combine -all and -short
- go doc: %s: %v %s
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/26dfbaf982897886.
Report an issue: GitHub.