Go "too many arguments in call" - Fix Signature Mismatches in CI
A function call passes the wrong number of arguments for the function’s signature. Most often a dependency upgrade changed a signature, and your call site was not updated to match.
What this error means
The build fails with too many arguments in call to <fn> or not enough arguments in call to <fn>, showing the expected and actual parameter lists. It is deterministic and points at the exact call.
./client.go:30:18: too many arguments in call to api.NewClient
have (string, *Options, context.Context)
want (string, *Options)Common causes
A dependency changed a function signature
An upgraded module added, removed, or reordered parameters. An unpinned upgrade breaks every call site that used the old signature.
A local refactor not propagated to all callers
A function’s parameters changed but one or more call sites were missed, so they pass the wrong count.
How to fix it
Update the call to the new signature
- Read the
have/wantlines to see the expected parameters. - Adjust the call site to match, consulting the dependency’s changelog/godoc for the new signature.
- Run
go build ./...to confirm all callers compile.
Pin the previous version if you cannot migrate yet
When the upgrade is unintended, pin back to the version whose signature your code expects.
go get github.com/org/api@v1.4.0
go mod tidyHow to prevent it
- Pin dependency versions and upgrade deliberately, reading changelogs.
- Update every call site when changing a local function signature.
- Build with
go build ./...before merging.