Welcome to the exciting world of programming with Go. This chapter introduces the language and creates a workspace where you can run your first Go program.
Meet the Go Language
Install the Go Tools
Create the Go Workspace
Write a Go Program
Run a Go Program
Format and Comment Code
Explore the VS Code Editor
Summary
Meet the Go Language
Go is a free open-source programming language created at Google by Robert Griesemer, Rob Pike, and Ken Thompson – best known for development of the Unix operating system. Google released version 1.0 of the Go language (“golang”) in March 2012, since when it has gained widespread popularity.
Go programs are written in plain text, then compiled into machine code by the Go compiler to produce an executable binary version.
The aims of the Go programming language are to be expressive, fast, efficient, reliable, and simple to write. Some programming languages, such as C or C++, are fast and reliable but not simple. Conversely, other programming languages such as Java or Python are simple to write but not so efficient.
Go is similar to the C programming language in many ways, and is sometimes referred to as a “C-like language” or “C for the 21st century”. But Go is much more than that, as it adopts good ideas from many other programming languages, yet avoids features that lead to complexity or unreliability.
Perhaps most importantly, Go introduces the ability to take advantage of multi-core CPU processing for concurrency using “goroutines” and “channels”. This provides the potential for the computer to deal with several things at the same time.
Although the Go language does not have the class structures found in Object Oriented Programming (OOP) languages, such as C++ or Java, its features do provide some degree of encapsulation, inheritance, and polymorphism – the three cornerstones of OOP.
The Go gopher – the iconic mascot of the Go programming language.
You can discover many more programming language books in the In Easy Steps series – including C, C++, C#, Java, and Python. Visit www.ineasysteps.com to find out more.
With so many programming languages to choose from, you may be wondering why you should choose to learn Go programming – so here are some of the advantages that Go offers:
Simple Syntax
The Go language is concise, like Python. It’s as simple to write as Python but is more efficient, like C++. This enables you to write code that is easy to read and maintain.
Compiled Language
The Go source code is compiled to binary machine code that can be read directly by the computer, instead of being interpreted every time a program runs. This enables the Go programs you write to run faster...