How to start learning Go

Go, or Golang, is a compiled multi-threaded programming language developed by Google. Rob Pike and Ken Thompson started work on it in 2007 with the goal of creating a fast, productive, and fun language without losing readability and simplicity. And as a result, they came up with Go, a language designed to simplify and speed up software development.

In this article, I will talk about aspects of Golang that you should pay attention to first of all, as well as provide links to modern resources for learning this programming language, which are best suited for novice developers.

What to look for when learning Go

Let’s start with the basic concepts that are usually included in any Go training course:

  1. First of all, you need to be aware of structures (structures or structs) and compositions of structures (composition). In simple terms, the first is a way to group objects of different types into one variable, and the second is a way to combine simple objects and data types into more complex ones, which is ultimately needed to create reusable code segments, since in this case a more complex object can use the functions of its component parts. And this is the key point in Go.

  2. Another important aspect is functions and methods. In Go, functions are not associated with any type – unlike methods. Methods are essentially the same functions, but when defining them, you must specify the recipient – an argument of the type to which the method is attached.

  3. Errors in Go are returned and checked explicitly. The developer himself determines which errors the method can return and implements their handling on the calling side. If the program encounters an error that the developer did not foresee, then panic and recover are used. The first one fires when the code cannot solve the current problem and stops the application from running. Recover returns control in case of a panic. Then the application is restored and continues in normal mode.

  4. It is also necessary to pay attention to standard Go libraries: fmt, net/http and others. The name of the first comes from the word formatting, and it allows you to format basic strings, values, and other objects, display them on the screen, and receive data from the user. As for net/http, it is a system package that helps developers create web servers and clients.

  5. Go is a language strong static typing, that is, each variable has its own immutable type. This property contributes to the simplicity of the code, makes it easy to read, and in addition, minimizes the risk of errors due to inattention.

  6. Do not forget about competitiveness (or concurrency) – a form of computing when several instructions are executed, intersecting, within the same time period. In Go, it is provided by gorutin (goroutings) and channels (channels): the former are functions that run concurrently with other goroutines in the same address space, and channels allow you to transfer structured data from one goroutine to another. The main advantage of goroutines over threads is that they are lightweight, as you can run hundreds of thousands of these functions on the same machine.

  7. To clean up memory, Go, unlike some other general-purpose languages, provides garbage collector (garbage collector) – an algorithm that scans the code for objects that slow down its work, and removes them. It provides high speed of program execution and efficient use of resources.

  8. Concerning OOP, then Go loses a little to other languages ​​- for example, it has no classes and inheritance. There is an explanation for this – in this way the creators of Go achieved minimal redundancy and ensured high speed of program execution.

  9. In terms of code organization in Go, it consists of packageswhich are divided into modules. Modularity allows you to define a package with the desired functionality once and then use it repeatedly in different programs. Modular code not only helps with organization, but also with maintenance, testing, and, most importantly, dependency management to combat excessive application complexity.

  10. Go supports automatic testing using the testing package, which is used by most developers, but the language ecosystem includes many other testing libraries, each with its own specifics. Debugging it is also possible using the standard GDB module or its advanced alternative – Delve.

Now you know what to pay special attention to when learning the basics of Go. Now is the time to get into action, and I have a selection of resources for you to help you learn most effectively. This is my personal selection, but rest assured that every course and every book has already passed the test of time and thousands (even millions) of sophisticated students. Go!

Resources for learning Go

Sites:

  1. golang.org – the official website of Go, where you can find the installation files themselves, all the documentation on the language (golang.org/doc), tutorials, books, courses, a blog, and more, as well as a sandbox to practice coding right in your browser.

  2. The Go Tour (tour.golang.org) is a subsection of the official site and an interactive introduction to the language.

  3. Go by example (gobyexample.com) is another introductory course in which the basic concepts of the language are explained using simple and understandable code examples.

Top courses:

  1. “Go: The Complete Developer’s Guide (Golang)” by Udemy. In this short 10-hour course, you’ll learn basic syntax and structures, the concept of concurrency, learn what types do, and learn how to organize code using packages. The course is rated 4.6 on Udemy, and the number of students who have completed the course is over 34,000, which indicates the quality of the presentation of the material.

  2. “Go Fundamentals” from Pluralsight. The four-hour course will help you understand basic concepts such as functions and conditional statements; you’ll learn how to create your own data types with structs and understand the basics of concurrency with goroutines.

  3. “Programming with Google Go”. A more detailed and in-depth course, hosted on the popular Coursera site, that will teach you how to write efficient and clean Go code while creating your own applications.

  4. “Learn How To Code: Google’s Go (golang) Programming Language” by Udemy. To take this course (45 hours of training), you do not need any prior programming skills – you will start with the basics. However, the course will also be useful for more experienced developers: the course contains many code examples, exercises and solutions for them, as well as a huge repository.

Learning Goon LinkedIn Learning. Another great short introductory course for developers.

Network Programming in Golang” by Udemy. A short two-hour course that will allow you to learn how to create TCP servers and clients and use them to transfer data over the network.

7) Specialization “Programming with Go” on Coursera. Specialization of three courses that cover the basic concepts of Go; functions, methods and interfaces; and competitiveness.

Best Books:

  1. “The Go Programming Language” (Alan AA Donovan, Brian W. Kernighan). This book is first on the list as it is good for beginners. The authors of the tutorial provide hundreds of examples of Go code from real scenarios; exercises fuel interest in a new language, and do not scare a novice programmer. The book is structured in such a way as to gradually lead the reader from basic concepts to more complex topics, while coding you will start from the very first pages.

  2. “Go in Action” (William Kennedy, Brian Ketelsen, Erik St. Martin). The book is intended for readers who already have programming experience in other languages. First, it reveals all the unique features of the language, after which the authors invite the reader to practice creating real applications, including websites and network servers, as well as learn how to quickly manipulate and convert data.

  3. “Go Web Programming” (Sau Sheong Chang). This book will help you figure out how to build scalable, high-performance Go web applications using modern design principles. It is assumed that the reader is already familiar with the basic concepts of Go and web development.

  4. “Mastering Go” (Mihalis Tsoukalos). The book is written for programmers who want to delve into the intricacies of writing Go code and learn how to create applications for solving real problems. It will help you understand topics such as concurrency and garbage collection, use Go with Docker, work with JSON files, and interact with databases.

Conferences

Of course, learning a language and – even more – working with it requires complete immersion, so you should always be aware of what’s new in the programming world and get to know colleagues more often. In this article, I also decided to share links to the most important and interesting conferences on Go that will be held in 2023:

  1. 20 April – CONF42: GOLANG 2023,

  2. April 28 – GOTHAMGO,

  3. 2 June – GO CONFERENCE 2023,

  4. June 26–29 – GOPHERCON EUROPE 2023,

  5. 26–29 September – GOPHERCON USA.

Write your first Go code

As you know, the best way to learn is by doing, so after mastering the basics it is useful to take on the creation of real applications, and here I can advise you to focus on web development using Go, since this language allows you to solve many tasks related to the web. To do this, you first need to learn net/http, the standard package for building HTTP servers in Go. Put your knowledge to the test and try building and running a simple web server in Go. I think that after this you will want to dive even deeper into the topic, and here I can recommend studying the popular frameworks for web development in Go – Gin, Echo and Revel.

Conclusion

In conclusion, I want to say that you can start writing working code in Go in just a couple of days after learning it, however, in order to become a real specialist and use the features that it offers most effectively, you need a lot of patience, constant curiosity and complete immersion in details and features of the language. In this article, I’ve outlined the most important topics and concepts to learn first, and provided links to resources that I think will help you along the way the best.

Good luck!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *