Go's Strict Type System Hits a JavaScript Developer: Variables, Zero Values, and the Cost of Implicit Conversion
Backend services consume string-shaped data from HTTP parameters, and Go forces every conversion to be explicit and error-checked. A developer who skips the `err` check after `strconv.Atoi` will ship a zero where a parse failure occurred, corrupting pagination, pricing, or query logic with no stack trace to flag it.
The first real Go project surfaces a cascade of compile-time rejections that JavaScript and TypeScript developers rarely encounter. Unused local variables and imports stop the build outright. The `:=` short declaration creates new variables inside blocks, silently shadowing outer names when `=` was intended. Numeric types refuse to interoperate: adding an int to a float64 requires an explicit cast, and converting float64 to int truncates toward zero without rounding.
String conversion delivers the sharpest surprise. `string(65)` produces `"A"`, not `"65"`, because Go treats the integer as a Unicode code point. Getting a decimal string requires `strconv.Itoa`, and parsing back with `strconv.Atoi` returns both a result and an error. A failed parse yields the int zero value `0`, which is indistinguishable from a successful parse of `"0"` unless the error is checked.
These constraints form a consistent philosophy: the compiler refuses to guess intent. Every type coercion, every unused symbol, and every shadowed variable must be resolved explicitly before the program runs. For a developer accustomed to JavaScript's permissive coercion, the friction is immediate, but it eliminates entire categories of runtime surprise.
Go treats unused symbols as a compilation failure, which feels pedantic during prototyping but prevents dead code from accumulating across a large module graph.
The `string()` vs `strconv.Itoa` distinction is a recurring trap for developers coming from JavaScript, Python, or Ruby, where a single `String()` or `str()` call handles decimal formatting.
Variable shadowing with `:=` inside blocks is syntactically legal and produces no warning, making it a stealthier source of bugs than the loudly enforced type errors.
Go's refusal to coerce numeric types forces a decision about precision loss at the call site, which matters acutely for financial calculations where implicit float conversion would silently drop cents.