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.
./api.go:12:6: syntax error: mixed named and unnamed parameters
# from: func Do(ctx context.Context, string) error // 'string' is unnamedCommon 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.
func Do(ctx context.Context, name string) error { ... } // all named
func Split(s string) (head string, tail string) { ... } // all named resultsOr make it consistently unnamed
If you do not need names, drop them from all entries in the list.
func Do(context.Context, string) error { ... } // all unnamedHow to prevent it
- Keep each parameter and result list all-named or all-unnamed.
- Run
gofmt/go vetso signature syntax errors surface immediately. - Prefer named results only when they aid readability, applied to every entry.