Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go language warnings and errors

Tags:

go

It seems that GO language does not have warnings in it. I've observed few instances. 1. "declared and not used"(if variable is declared and not used anywhere it gives an error and does not compile the program) 2. "imported and not used"(similarly if package is imported and not used anywhere it gives an error and does not compile the program) Can somebody help. If they have any pointers.

like image 360
Anuj Verma Avatar asked Aug 14 '11 20:08

Anuj Verma


1 Answers

Go is trying to prevent this situation:

The boy is smoking and leaving smoke rings into the air. The girl gets irritated with the smoke and says to her lover: "Can't you see the warning written on the cigarettes packet, smoking is injurious to health!"

The boy replies back: "Darling, I am a programmer. We don't worry about warnings, we only worry about errors."

Basically, Go just wont let you get away with unused variables and unused imports and other stuff that is normally a warning on other languages. It helps put you in a good habit.

like image 137
Dair Avatar answered Sep 30 '22 16:09

Dair