Install and Setup
If you're thinking about engineering the next big dotcom application then you should seriously consider using Go!!
The Go Programming Language is without doubt one of the hottest languages to learn, particularly in this cloud native era. More and more companies are adopting Go to engineer highly performant, stable and maintainable applications. Popular projects such as Docker, Kubernetes, Terraform, Etcd, Istio, InfluxDB have all been built successfully using Go!!
This introductory level training course is designed to bring you quickly up to speed with the many key features that the Go programming language provides. You'll also learn how to setup your own Go development environment - consisting of the Go toolchain, Visual Studio Code, and several related Go based extensions - all to ensure that you are able to be productive writing your own source code.
We’d love to get your feedback on this course, so please give it a rating when you’re finished. If you have any queries or suggestions, please contact us at email@example.com.
By completing this course, you will:
- Learn about what makes Go a great language
- Learn how to install the Go toolchain
- Learn how to setup Visual Studio Code to edit and debug Go programs
- Learn how to work with the Go Playground to test and run snippets of Go code
- Learn and understand the basic Go language syntax and features
- Learn how to use the Go tool chain commands to compile, test, and manage Go code
- And finally, you’ll learn how to work with and manage Go modules for module dependency management
This course is intended for:
- Anyone interested in learning the Go Programming Language
- Software Developers interested in using Go to compile and test Go based applications
- DevOps practitioners looking to learn about Go to support Go based applications
To get the most from this course, you should have at least:
- A basic understanding of software development and the software development life cycle
All sample Go source code as used and demonstrated within this course can be found here:
- [Jeremy Cook] Channels can be iterated over. That is, you can use the range keyword in the same manner as you would when using it with arrays, slices, and/or maps. This allows you to quickly and easily iterate over the messages that exist within a channel. In the example provided here, on lines five to 11, I've created a squares function that returns another function which implements returning a sequence of squares.
In the main function on lines 17, 18 and 19, I use a simple for loop to load up the squares channel with all the squares of whole numbers where the square is less than or equal to 100. Finally, on lines 23 to 25 I use another for loop with the range keyword to iterate over the current contents of the squares channel. Note, it's very important to close a channel before iterating over the messages within the channel. Without doing this, the program would eventually panic due to a deadlock.
Closing the channel in this example also highlights an important point about closing channels, and that is you can still read from them after they are closed, you just can't continue to send messages to them if they have been closed. Running this example results in the following output. Let's now comment out the close function on line 21 and then rerun the program. This results in a deadlock, as earlier explained.
In summary, you've just observed how to use the range keyword with a for loop to iterate over the messages within a named channel, how closing a channel before iterating over it is important to avoid deadlocking, and that you can still read from a channel after it has been closed.
About the Author
Jeremy is the DevOps Content Lead at Cloud Academy where he specializes in developing technical training documentation for DevOps.
He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 20+ years. In recent times, Jeremy has been focused on DevOps, Cloud, Security, and Machine Learning.
Jeremy holds professional certifications for both the AWS and GCP cloud platforms.