golang/go · warning

no symbol %s in package%s

Error message

no symbol %s in package%s

What it means

Returned by go doc's failMessage when a symbol lookup found the package but not the requested symbol and no method component was given. The message lists every package path searched (pluralized with 's' when more than one) so the user can see where the lookup failed.

Source

Thrown at src/cmd/go/internal/doc/doc.go:356

	}
	return path, object, nil
}

// 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 {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. List symbols with `go doc <pkg>` to confirm the exact exported name.
  2. Check spelling and capitalization (Go is case-sensitive).
  3. If the symbol is unexported, it is intentionally not documented.
  4. Disambiguate the package path (rand -> math/rand or crypto/rand).

Example fix

# before
$ go doc math/rand.notasymbol
# -> no symbol notasymbol in package math/rand

# after: list first, then query
$ go doc math/rand
$ go doc math/rand.Intn
Defensive patterns

Strategy: validation

Validate before calling

// verify a symbol exists before deep use
if out, _ := exec.Command("go", "doc", "-all", pkg).Output(); !bytes.Contains(out, []byte(symbol)) {
    return fmt.Errorf("symbol %s not found; run `go doc %s`", symbol, pkg)
}

Prevention

When it happens

Trigger: Running `go doc <pkg>.<Symbol>` where <Symbol> does not exist in the resolved package(s); parseSymbol split off no method portion, so the bare-symbol branch is taken.

Common situations: Typo'd exported identifier; referencing an unexported symbol without realizing it; stale memory of an API renamed across versions; querying the wrong import path among duplicates (e.g. crypto/rand vs math/rand).

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/7e56c9709a7355e6. Report an issue: GitHub.