To import a package with an alias in go, you can use the import
keyword followed by the package path and the desired alias after the as
keyword. Here is an example:
main.go85 chars8 lines
In this example, we have aliased the fmt
package as fmtAlias
. We can now access all the exported functions and variables of the package using the alias fmtAlias
.
Note that the package name used in the code should match the alias used in the import statement.
gistlibby LogSnag