{"record":{"id":"26dfbaf982897886","repo":"golang/go","slug":"no-method-or-field-s-s-in-package-s","errorCode":null,"errorMessage":"no method or field %s.%s in package%s","messagePattern":"no method or field (.+?)\\.(.+?) in package(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/go/internal/doc/doc.go","lineNumber":358,"sourceCode":"}\n\n// failMessage creates a nicely formatted error message when there is no result to show.\nfunc failMessage(paths []string, symbol, method string) error {\n\tvar b bytes.Buffer\n\tif len(paths) > 1 {\n\t\tb.WriteString(\"s\")\n\t}\n\tb.WriteString(\" \")\n\tfor i, path := range paths {\n\t\tif i > 0 {\n\t\t\tb.WriteString(\", \")\n\t\t}\n\t\tb.WriteString(path)\n\t}\n\tif method == \"\" {\n\t\treturn fmt.Errorf(\"no symbol %s in package%s\", symbol, &b)\n\t}\n\treturn fmt.Errorf(\"no method or field %s.%s in package%s\", symbol, method, &b)\n}\n\n// parseArgs analyzes the arguments (if any) and returns the package\n// it represents, the part of the argument the user used to identify\n// the path (or \"\" if it's the current package) and the symbol\n// (possibly with a .method) within that package.\n// parseSymbol is used to analyze the symbol itself.\n// The boolean final argument reports whether it is possible that\n// there may be more directories worth looking at. It will only\n// be true if the package path is a partial match for some directory\n// and there may be more matches. For example, if the argument\n// is rand.Float64, we must scan both crypto/rand and math/rand\n// to find the symbol, and the first call will return crypto/rand, true.\nfunc parseArgs(ctx context.Context, flagSet *flag.FlagSet, args []string) (pkg *load.Package, path, symbol string, more bool) {\n\twd, err := os.Getwd()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/doc/doc.go#L340-L376","documentation":"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.","triggerScenarios":"Running `go doc <pkg>.<Type>.<Method>` where <Method> is not a method or field of <Type> in the resolved package(s).","commonSituations":"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.","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."],"exampleFix":"# before\n$ go doc os.File.NotAMethod\n# -> no method or field File.NotAMethod in package os\n\n# after\n$ go doc os.File\n$ go doc os.File.Read","handlingStrategy":"validation","validationCode":"// enumerate methods of the type before assuming one exists\nif out, _ := exec.Command(\"go\", \"doc\", pkg+\".\"+typ).Output(); !bytes.Contains(out, []byte(method)) {\n    return fmt.Errorf(\"method %s missing on %s; see `go doc %s.%s`\", method, typ, pkg, typ)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["doc","symbol","method","lookup"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}