| 1. |
What are Golang packages? |
|
Answer» Go Packages (in short PKG) are nothing but directories in the Go workspace that contains Go source files or other Go packages themselves. Every single PIECE of code starting from variables to functions are written in the source files are in turn stored in a linked package. Every source file should belong to a package. From the image below, we can SEE that a Go Package is represented as a box where we can store multiple Go source files of the .go extension. We can also store Go packages as well within a package. The package is declared at the top of the Go source file as package <package_name> The packages can be imported to our source file by writing: IMPORT <package_name> An example of the Go package is fmt. This is a standard Go Package that has formatting and printing functionalities such as Println(). |
|