To import the fmt
package with a blank identifier in Go, use the following code:
main.go15 chars2 lines
The underscore character _
is used to assign the imported package to the blank identifier, which discards the visibility of that package in the code.
This is generally used when you need to import a package just for its side effects, like running its init()
function, without actually using any of its features or functions in the code.
gistlibby LogSnag