To import a package without using any of its exported identifiers, you can use the blank identifier symbol _
. This tells the Go compiler to import the package solely for its side effects.
Here is an example of how to import the fmt
package with a blank identifier:
main.go15 chars2 lines
This line of code should be placed in the import section of a Go file, before any other imports or code. Importing packages with the blank identifier can be useful for libraries that have a required self-registration step without requiring you to use any of its exported identifiers within your source code.
gistlibby LogSnag