Imports
Learn about imports in Go.
We'll cover the following...
We'll cover the following...
Unused imports
Go programs with unused imports don’t compile. This is a deliberate feature of the language since importing packages slows down the compiler. In large programs, unused imports could make a significant impact on compilation time.
To keep the compiler happy during development, you can reference the package in some way:
goimports
A better solution is to use the goimports tool. goimports removes
unreferenced imports. What’s even better is that the following widget does not use goimports and the compilation fails
After running goimports:
./goimports main.go
In the above code, goimports removes the unreferenced import math ...