Download 100 Go Mistakes AND HOW TO AVOID THEM
100 Go Mistakes AND HOW TO AVOID THEM Book Details
Title: 100 Go Mistakes AND HOW TO AVOID THEM
Author: TEIVA HARSANYI
Language: English
No. of pages: 385
Format: PDF, EPUB
Preface
In 2019, I started my second professional experience with Go as the primary language. While working in this new context, I noticed some common patterns regarding Go coding mistakes. I started to think that perhaps writing about these frequent mistakes could help some developers.
So, I wrote a blog post called “The Top 10 Most Common Mistakes I’ve Seen in Go Projects.” The post was very popular: it had more than 100,000 reads and was selected by the Golang Weekly newsletter as one of the top articles of 2019. Beyond that, I was pleased with the positive feedback I got from the Go community.
From that moment, I realized that communicating about common mistakes was a powerful tool. Accompanied by concrete examples, it can help people learn new skills efficiently and facilitate remembering the context of a mistake and how to avoid it.
I spent about a year compiling mistakes from various sources such as other profes- sional projects, open source repositories, 100 Go Mistakes AND HOW TO AVOID THEM books, blogs, studies, and discussions with the Go community. To be transparent, I was also a decent source of inspiration regard- ing mistakes.
100 Go Mistakes and How to Avoid Them
About this book 100 Go Mistakes AND HOW TO AVOID THEM
100 Go Mistakes and How to Avoid Them contains 100 common mistakes made by Go developers when working with various aspects of the language. It focuses heavily on the core language and the standard library, not external libraries or frameworks. The discussions of most of the mistakes are accompanied by concrete examples to illus- trate when we are likely to make such errors. It’s not a dogmatic book : e100 Go Mistakes AND HOW TO AVOID THEMach solution is detailed to convey the context in which it should apply.
Who should read this 100 Go Mistakes AND HOW TO AVOID THEM book
This book is for developers with existing knowledge of the Go language. It doesn’t review basic concepts such as syntax or keywords. Ideally, you have already worked on an existing Go project at work or home. But before delving into most topics, we make sure the foundations are clear.
100 Go Mistakes and How to Avoid Them consists of 12 chapters:
- Chapter 1, “100 Go Mistakes AND HOW TO AVOID THEM Go: Simple to learn but hard to master,” describes why despite being considered a simple language, Go isn’t easy to master. It also shows the different types of mistakes we cover in the book.
- Chapter 2, “Code and project organization,” contains common mistakes that can prevent us from organizing a codebase in a clean, idiomatic, and maintain- able manner.
- Chapter 3, “Data types,” discusses mistakes related to basic types, slices, and maps.
- Chapter 4, “Control structures,” explores common mistakes related to loops and other control structures.
- Chapter 5, “Strings,” looks at the principle of string representation and com- mon mistakes leading to code inaccuracy or inefficiency.
- Chapter 6, “Functions and methods,” explores common problems related to functions and methods, such as choosing a receiver type and preventing com- mon defer bugs.
- Chapter 7, “Error management,” walks through idiomatic and accurate error handling in Go.
- Chapter 8, “Concurrency: Foundations,” presents the fundamental concepts behind concurrency. We discuss topics such as why concurrency isn’t always faster, the differences between concurrency and parallelism, and workload types.
- Chapter 9, “Concurrency: Practice,” looks at concrete examples of mistakes related to applying concurrency when using Go channels, goroutines, and other primitives.
- Chapter 10, “The standard library,” contains common mistakes made when using the standard library with HTTP, JSON, or (for example) the time API.
- Chapter 11, “Testing,” discusses mistakes that make testing and benchmarking more brittle, less effective, and less accurate.
- Chapter 12, “Optimizations,” closes the 100 Go Mistakes AND HOW TO AVOID THEM book by exploring how to optimize an application for performance, from understanding CPU fundamentals to Go- specific topics. About the code This book contains many examples of source code both in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes code is also in bold to high- light code that has changed from previous steps in the chapter, such as when a new feature adds to an existing line of code. In many cases, the original source code has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. In some cases, even this was not enough, and listings include line-continuation markers (➥). Additionally, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts. You can get executable snippets of code from the liveBook (online) version of this book at https://livebook.manning.com/book/100-go-mistakes-how-to-avoid-them. The complete code for the examples in the book is available for download from the Manning website at https://www.manning.com/books/100-go-mistakes-how-to-avoid -them, and from GitHub at https://github.com/teivah/100-go-mistakes.
Purchase of 100 Go Mistakes and How to Avoid Them includes free access to liveBook, Manning’s online reading platform. Using liveBook’s exclusive discussion features, you can attach comments to the book globally or to specific sections or paragraphs. It’s a snap to make notes for yourself, ask and answer technical questions, and receive help from the author and other users. To access the forum, go to https://livebook .manning.com/book/100-go-mistakes-how-to-avoid-them/discussion. You can also learn more about Manning’s forums and the rules of conduct at https://livebook .manning.com/discussion.
Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We sug- gest you try asking the author some challenging questions lest his interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
At the end of 2020, I reached 100 Go mistakes, which seemed to me like the right moment to propose my idea to a publisher. I contacted only one: Manning. I saw Man- ning as a top-level company known for publishing high-quality books, and to me, it was the perfect partner. It took me almost 2 years and countless iterations to frame each of the 100 mistakes alongside meaningful examples and multiple solutions where context is key.
I hope this book will help you avoid making these common mistakes and help you enhance your proficiency in the Go language.