Go "cannot use X (variable of type A) as B value" - Fix in CI
Go is statically typed and never implicitly converts between types. Passing a value whose type does not match the parameter is a compile error.
What this error means
A build fails with cannot use x (variable of type A) as B value in argument to f. It commonly follows a signature change or a refactor that altered a value type.
./api.go:21:14: cannot use id (variable of type int64) as string value in argument to lookupCommon causes
Signature changed
A parameter type changed but a caller still passes the old type.
Missing explicit conversion
Go requires an explicit conversion between numeric or named types; the call omitted it.
How to fix it
Convert the value explicitly
- Wrap the argument in the target conversion, or fix the caller to pass the right type.
lookup(strconv.FormatInt(id, 10))Align callers with the signature
- Update every call site after changing a function signature, then rebuild.
go build ./...How to prevent it
- Update all call sites when you change a signature.
- Build locally before pushing to catch type mismatches.
- Prefer explicit conversions over relying on inference.