go-delve/delve · error

%s (type %s) has no member %s

Error message

%s (type %s) has no member %s

What it means

This error is thrown by Delve's expression evaluator (pkg/proc/eval.go) when you evaluate a member access like `v.Field` or `v.Method()` on a struct value, and the resolved struct type has no field or method with that name, even after searching promoted/embedded members and methods (including pointer-receiver methods). It is the evaluator's way of reporting a name-resolution failure on struct member lookup.

Source

Thrown at pkg/proc/eval.go:3148

				}
				// Check for embedded field referenced by type name
				parts := strings.Split(field.Name, ".")
				if includeStructMember && len(parts) > 1 && parts[1] == name {
					return embeddedVar, nil
				}
				embeddedVar.Name = structVar.Name
				queue = append(queue, embeddedVar)
			}
		case *godwarf.InterfaceType:
			v.loadInterface(0, false, LoadConfig{})
			if len(v.Children) > 0 {
				if rv, _ := v.Children[0].findStructMemberOrMethod(name, false); rv != nil {
					return rv, nil
				}
			}
		default:
			if first {
				return nil, fmt.Errorf("%s (type %s) has no member %s", vname, structVar.TypeString(), name)
			}
		}
		first = false
	}

	return nil, fmt.Errorf("%s has no member %s", vname, name)
}

func lookupMethod(v *Variable, isptr bool, pkg, receiver, name string) (*Variable, error) {
	checks := []struct {
		fmt     string
		ptrRecv bool
	}{
		{"%s.(*%s).%s", true},
		{"%s.%s.%s", false},
	}
	if !isptr {
		checks[0], checks[1] = checks[1], checks[0]

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Print the variable itself (e.g. `print v`) or use tab completion to list actual members and correct the name in the expression
  2. Check the struct definition (embedded fields, promoted methods) with `whatis v` and the source to confirm the member exists and its promotion path
  3. If a breakpoint condition or watch expression uses the old name, update or delete it after refactoring
  4. Rebuild/reload the binary so debug info matches the source you are reading

Example fix

// before (Delve CLI, struct has no field Nam)
(dlv) print p.Nam
// error: main.Point (type main.Point) has no member Nam
// after
(dlv) print p.Name
Defensive patterns

Strategy: validation

Validate before calling

// Before relying on member access, confirm the member exists:
// (dlv) print v            // dumps the struct incl. all fields
// (dlv) whatis v           // prints the type
// In Go code driving delve programmatically:
if _, err := evalExpr("v"); err != nil { return err }
// only then evaluate "v.Field"

Type guard

func hasMember(client *rpc2.RPCClient, expr, member string) bool {
    v, err := client.EvalVariable(expr, ...)
    if err != nil { return false }
    for _, ch := range v.Children {
        if ch.Name == member { return true }
    }
    return false
}

Try / catch

val, err := evalExpr("v.Field")
if err != nil && strings.Contains(err.Error(), "has no member") {
    // fall back to printing the whole struct for the user
    val, err = evalExpr("v")
}

Prevention

When it happens

Trigger: Evaluating an expression in the debugger (print/display, breakpoint condition, watchpoint) that selects a member on a struct/interface-typed variable, where: (1) the field name is misspelled, (2) the field belongs to a different struct, (3) the method is unexported and on a type from another package, or (4) the embedded/promoted path you assume does not exist.

Common situations: Typos in field names during interactive debugging; assuming an embedded struct promotes a member it does not; accessing a method on the value (not pointer) type where the method requires a pointer the debugger cannot synthesize; refactoring renamed a field while old breakpoint conditions or watch expressions persist; debugging a binary built from source that no longer matches the type (stale binary).

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/724d7cce8d035aa2. Report an issue: GitHub.