Avatar ·

What does the underscore symbol before a package import mean in Go?

Hello everyone! I just started learning Go and came across a construct I don't understand. In someone else's code, I saw a package import with an underscore symbol before the package name: ```go import ( "fmt" _ "github.com/lib/pq" "database/sql" ) ``` I understand that `_` in Go is used as a blank identifier when we want to ignore a function's return value. But what does it do in an import? After all, if we import a package, we usually use it in the code, but here it's explicitly stated that we don't use it (otherwise the compiler would throw an error). I tried removing this import, and the code stopped working — the compiler gave an error that the driver for PostgreSQL was not found. But at the same time, the `pq` package itself is not used anywhere in the code. How is this possible? Why is it needed?