Search⌘ K
AI Features

Go Packages

Explore how Go packages are structured and used in programming. Understand the process of downloading and managing external packages using tools like go get and go mod for better project organization and dependency management.

Everything in Go is delivered in the form of packages. A Go package is a Go source file that begins with the package keyword, followed by the name of the package.

Note: Note that packages can have structure. For example, the net package has several subdirectories named http, mail, rpc, smtp, textproto, and url, which should be imported as net/http, net/mail, net/rpc, net/smtp, net/textproto, and net/url, respectively.

Apart from the packages of the Go standard library, there are external packages that can be imported using their full address, and that should be downloaded on the local machine before their first use. One such example is cobra, which is stored in GitHub. ... ...