Install and Setup
The course is part of this learning path
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] As previously mentioned, the Go language specification uses a naming convention whereby variables, constants, functions, et cetera, that you want to export and make available to be imported elsewhere are named with a starting capital letter.
Anything that begins with a lowercase letter is determined to be unexported and therefore not importable. In other languages such as C# and Java, this type of control is implemented using dedicated modified keywords such as public and private. To see this in action, consider the example provided here. For starters, this example is a multi-file example, the first of which we've seen and used so far. The double-dash lines are the demarkation points for the start and end of each file. These are located on lines one, four, and 20. You will only require these to model and test multi-file designs within the Go Playground. They are not considered part of the formal Go language syntax.
In this example we have three files. The files go.mod and main.go are both located in the root directory of the example while the x.go file is located in a directory named util. The go.mod file is used to declare a module which is used to organize and contain the util package which is later imported within the main.go file. The x.go utility file is declared to be in the util package as per the package statement at the top. Within this file, there are two constants declared on lines seven and eight, one named with an uppercase X, ensuring that it is an exported constant, and the other with a lowercase x which makes it an unexported constant.
Next up are two functions declared on lines 11 to 13 and lines 15 to 18. Both functions share the same name, albeit the first beginning with a capital G making it exported and the other one starting with a lowercase g making it unexported. The main.go file which begins on line 21 imports the util package contained in the module declared above. Within the main function, the util.X constant is accessed on line 29. This is possible since it was made exportable within the util package as earlier explained. The equivalent lowercase x constant if accessed would not be possible and would actually cause a compile time error if attempted. Likewise the same behavior happens for the invocation of the GetX functions on lines 32 and 33.
The point here is that the naming convention dictates whether it is exported or not and therefore whether it can be visible in other packages. Running this example returns the values 100 and 200. Let's alter the program by attempting to access the unexported constant and function like so. Rerunning the program now throws a compile time error as expected. Note that this is a compile time error, not a run time error.
In summary, you have observed that the starting letter for variables, constants, functions, et cetera, dictates whether they are exported or not therefore whether they are visible in other packages. If the name starts with a capital letter, then it is exported otherwise not.
Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.
He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, GCP, Azure), Security, Kubernetes, and Machine Learning.
Jeremy holds professional certifications for AWS, GCP, and Kubernetes.