Using the Go Playground
The Go Playground, which you can find at https://play.golang.org/, is an online code editor and compiler that allows you to run Go code without installing Go on your machine. This is the perfect tool for our introductory chapters, allowing you to save your work online without the initial fuss of installing the Go tooling, or finding a code editor, for example.
There are four important parts of the Go Playground:
- The code editing pane
- The console window
- The Run button
- The Share button
The code editing pane, which is the yellow portion of the page, allows you to type in the Go code for your program. When you hit the Run button, the code will be compiled and then run with the output sent to the console, which is the white portion of the page below the code editor.
The following screen shows a glimpse of what the Go Playground does:
Clicking the Share button will store an immutable copy of the code and will change the URL from play.golang.org
into a shareable link, such as play.golang.org/p/HmnNoBf0p1z
. This link is a unique URL that you can bookmark and share with others. The code in this link cannot be changed, but if you hit the Share button again, it will create a new link with any changes.
Later chapters, starting with Chapter 4, Filesystem Interaction, will require installing the Go tooling for your platform.
This section taught you about the Go Playground and how to use it to write, view, share, and run your Go code. The Playground will be used extensively throughout the book to share runnable code examples.
Now, let's jump into writing Go code, starting with how Go defines packages.