Go "cannot use X as Y value in argument" - Fix in CI
Go is statically typed and will not implicitly convert 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 type B value in argument to f. It commonly appears after a signature change or a refactor that altered a value type.
./api.go:18:14: cannot use id (variable of type int64) as type string value in argument to lookupCommon causes
Signature changed
A function 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 type conversion, or fix the caller to pass the right type.
lookup(strconv.FormatInt(id, 10))Align caller and signature
- Update all callers 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.