Menu

Go errors in your first months: strict compiler, module confusion, and runtime panics
📰

Go errors in your first months: strict compiler, module confusion, and runtime panics

DEV Community: backend·Hollis·3 days ago
#vKxFlqiP
#devtobackend#devto#dev#value#used
Long article (660 words) — no AI summary yet.
Reading 0:00
15s threshold

Go's compiler is strict on purpose: unused variables and imports are errors, not warnings. Its runtime panics are blunt too. Here are the errors most Go developers hit in their first few months, grouped by when they happen.

Compile time: the compiler is being strict

declared and not used / "fmt" imported and not used

Go refuses to compile code with unused variables or imports. While debugging, assign to the blank identifier or let your editor manage imports:

_ = result // temporary: silence "declared and not used"

Enter fullscreen mode

Exit fullscreen mode

goimports or gopls adds and removes imports automatically on save.

no new variables on left side of :=

:= declares variables. If every name on the left already exists in that scope, use = . With several names, := works as long as at least one is new, which is why x, err := f() works on a second line that introduces x .

undefined: X

The name doesn't exist in this package or isn't exported.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.