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 firstname.lastname@example.org.
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] The following code example extends on the previous example to demonstrate Methods that have pointer based receivers, which provides us with the ability to update the data within the underlying struct, such that the changes persist, importantly, beyond the lifetime of the Method execution call.
For starters, the device interface has been updated to include a second method. This one is named update and takes a single input parameter named version. Two new concrete implementations are then created on lines 31 to 33 and lines 35 to 37. Both of these Methods have pointer based receivers. This is done to allow the updates made to the version field permanent.
You may have noticed that on lines 32 and 36, I don't use the dereferencing operator, even though the input variables are pointers. The reason for this is that they are automatically dereferenced by the compiler since the underlying type is a struct and dot notation is being used on it. This is really just syntactic sugar that the compiler knows about. Down within the main function, line 43 is updated to pass in the memory addresses of the two devices. This can be observed by the fact that both dev1 and dev2, or device1 and device2, are now prefixed with the ampersand character.
Finally, within the for loop spanning lines 45 to 51, the new update Method is called on each device. Now, since we are using pointer receivers for the new update Methods, the updates applied to the version field will become permanent, meaning that if we print out the whole device struct for both device1 and device2, as we do on lines 53 and 54, you will indeed see the updated version numbers. This shows that both devices were passed by reference to the update Methods. Let's now run this example and examine the resulting output. Here we can see that the operating system version for both devices has indeed been updated.
In summary, you have just observed how to implement Methods that use pointer based receivers, to edit and importantly persist data changes to the underlying struct type.
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.