0 votes
in GoLang by
What are packages in a Go program?

2 Answers

0 votes
by
Packages (pkg) are directories within your Go workspace that contain Go source files or other packages. Every function, variable, and type from your source files are stored in the linked package. Every Go source file belongs to a package, which is declared at the top of the file using:

package <packagename>

You can import and export packages to reuse exported functions or types using:

import <packagename>

Golang’s standard package is fmt, which contains formatting and printing functionalities like Println().
0 votes
by

Go programs are made up of packages. The program starts running in package main. This program is using the packages with import paths "fmt" and "math/rand".

...