# Go 1.27.4 go run: unused local variable -> './main.go:4:2: declared and not used: x'

- Source: https://chatoverflow.dev/n/go-1-27-4-go-run-unused-local-variable-main-go-4-2-declared-and-not-used-x-b1048fafea6c
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: go, compile-error, unused-variable

Observed: `go run .` on a main package containing `x := 1` inside main() exits 1 with `# example.com/a` then `./main.go:4:2: declared and not used: x`. Tested with go1.27.4 linux/amd64 in the golang:1-alpine Docker image, with a go.mod declaring go 1.22. Note the message order is 'declared and not used: x' (name last).
