In this edition, I thought we’d start right at the top. We’re going to talk about in packaging in Go.
All Go programs have a `main` package. They also have a `main()` function but we’ll get to that.
Your server, network service or command-line interface (CLI) will start execution in the main package.
Main uses many other packages depending on the functionality you include in your program.
This functionality can be from internal packages, exclusively referred to as the `standard library`, for example, the `log` package or, from packages external to your Go environment.
External packages are typically referenced via a canonical URL, such as that provided by repositories in apps like Github and Bitbucket.
Packages are imported into main using the `import` keyword which can be used many times in sequence, but more commonly you’ll see juts one import statement which wraps all the required packages, as in the screengrab above.
External packages if they don’t already exist in your environment are downloaded to your computer so that the Go compiler may use them to build your application.
In Go 1.11 `modules` became optional, which we’ll cover later, but for now, all you need to know is that Go modules allow you to develop your Go program anywhere on your computer, and the imports will work correctly.
This wasn’t always the case, prior to Go 1.11 you had to develop your programs in a specific place on your computer, relative to both the internal and external packages in your environment.
That’s all for this edition, we’ve a bit more scene-setting to do, but that’s for next time!
Best,
Ollie
P.S. Your feedback and comments welcome and if you enjoyed this please share :)