Skip to content
Latchkey

Go "mixed named and unnamed parameters" - Fix Signatures in CI

A function signature mixes named and unnamed entries in one parameter or result list. Go requires every entry in a list to be all named or all unnamed, so the mixed form is a syntax error.

What this error means

The build fails to parse with syntax error: mixed named and unnamed parameters (or ... function results), pointing at the signature. Nothing past it compiles because the declaration is malformed.

go build output
./api.go:12:6: syntax error: mixed named and unnamed parameters
# from: func Do(ctx context.Context, string) error  // 'string' is unnamed

Common causes

Some parameters named, others not

Writing func f(a int, string) names a but leaves the second parameter unnamed. Within one list Go demands all-named or all-unnamed.

Mixed named and unnamed return values

A result list like (n int, error) mixes a named result with an unnamed one, which is the same forbidden mix on the results side.

How to fix it

Make the list consistently named

Give every parameter (or result) a name when any of them are named.

Go
func Do(ctx context.Context, name string) error { ... }      // all named
func Split(s string) (head string, tail string) { ... }     // all named results

Or make it consistently unnamed

If you do not need names, drop them from all entries in the list.

Go
func Do(context.Context, string) error { ... }   // all unnamed

How to prevent it

  • Keep each parameter and result list all-named or all-unnamed.
  • Run gofmt/go vet so signature syntax errors surface immediately.
  • Prefer named results only when they aid readability, applied to every entry.

Related guides

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