Skip to content
Latchkey

Go "t.Method undefined (type T has no field or method Method)" in CI

The compiler resolved the receiver type and found no field or method by that name. The name may be misspelled, unexported from another package, or defined on a different type or a pointer receiver.

What this error means

Compilation fails with "t.Method undefined (type T has no field or method Method)" at a method call or field access.

go build
./svc.go:24:11: c.Fetch undefined (type *Client has no field or method Fetch)

Common causes

A typo or a renamed method

The method name does not match what the type declares, often after a rename that missed this caller.

A pointer vs value receiver mismatch, or an unexported name

The method exists on *T but you hold a T value (or vice versa), or the name is lowercase and not exported from its package.

How to fix it

Call the correct, exported method

  1. Check the type definition for the exact method name and receiver.
  2. Fix the spelling, or take the address (&v) if the method has a pointer receiver.
  3. For cross-package use, confirm the method is exported (capitalized).
svc.go
// method has a pointer receiver
c := &Client{}
c.Fetch(ctx)

Update callers after a rename

When you rename a method, update every caller in the same change so none references the old name.

How to prevent it

  • Build the whole module in CI so missing methods surface.
  • Use editor "find references" when renaming methods.
  • Keep pointer and value receivers consistent across a type.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →