The authoritative resource to writing clear and idiomatic Go to solve real-world problems
Google’s Go team member Alan A. A. Donovan and Brian Kernighan, co-author of The C Programming Language, provide hundreds of interesting and practical examples of well-written Go code to help programmers learn this flexible, and fast, language. It is designed to get you started programming with Go right away and then to progress on to more advanced topics.
Basic components: an opening tutorial provides information and examples to get you off the ground and doing useful things as quickly as possible. This includes:
command-line arguments
gifs
URLs
web servers
Program structure: simple examples cover the basic structural elements of a Go program without getting sidetracked by complicated algorithms or data structures.
Data types: Go offers a variety of ways to organize data, with a spectrum of data types that at one end match the features of the …
The authoritative resource to writing clear and idiomatic Go to solve real-world problems
Google’s Go team member Alan A. A. Donovan and Brian Kernighan, co-author of The C Programming Language, provide hundreds of interesting and practical examples of well-written Go code to help programmers learn this flexible, and fast, language. It is designed to get you started programming with Go right away and then to progress on to more advanced topics.
Basic components: an opening tutorial provides information and examples to get you off the ground and doing useful things as quickly as possible. This includes:
command-line arguments
gifs
URLs
web servers
Program structure: simple examples cover the basic structural elements of a Go program without getting sidetracked by complicated algorithms or data structures.
Data types: Go offers a variety of ways to organize data, with a spectrum of data types that at one end match the features of the hardware and at the other end provide what programmers need to conveniently represent complicated data structures.
Composite types:
arrays
slices
maps
structs
JSON
test and HTML templates
Functions: break a big job into smaller pieces that might well be written by different people separated by both time and space.
Methods:
declarations
with a pointer receiver
struct embedding
values and expressions
Interfaces: write functions that are more flexible and adaptable because they are not tied to the details of one particular implementation.
Concurrent programming: Goroutines, channels, and with shared variables.
Packages: use existing packages and create new ones.
Automated testing: write small programs that check the code.
Reflection features: update variables and inspect their values at run time.
Low-level programming: step outside the usual rules to achieve the highest possible performance, interoperate with libraries written in other languages, or implement a function that cannot be expressed in pure Go.
Each chapter has exercises to test your understanding and explore extensions and alternatives. Source code is freely available for download and may be conveniently fetched, built, and installed using the go get command.
I can definitely recommend this book to anybody wanting to learn Go. It contains lots of helpful examples and does a great job at explaining Go's concepts. It doesn't only show you the syntax, but also how something works under the hood.
Additionally, it's full of helpful advice and best practices.
Review of 'The Go programming language' on 'Goodreads'
4 stars
My attitude towards Go in the past has been one of superior contempt. After all, I had visited the higher planes of programming, where one can see macros and monads in their full brilliance, and thus relegated Go to the unwashed masses. On the few occasions I had used it--alas, professional programmers are merely mercenaries--it was surprisingly easy to write. Almost enjoyable. But no, I had seen the pure snows on the peaks of the Olympian mountains of abstraction. Once you breathe the rarefied air of higher abstraction you can't wallow in the mud that is programming in lesser languages. So I continued to look down on Go and its users.
I have crossed paths with this book a number of times. I leafed through it, I even read the introduction, but I never picked it up properly. This changed because, of all things, a book on Zen Buddhism. You …
My attitude towards Go in the past has been one of superior contempt. After all, I had visited the higher planes of programming, where one can see macros and monads in their full brilliance, and thus relegated Go to the unwashed masses. On the few occasions I had used it--alas, professional programmers are merely mercenaries--it was surprisingly easy to write. Almost enjoyable. But no, I had seen the pure snows on the peaks of the Olympian mountains of abstraction. Once you breathe the rarefied air of higher abstraction you can't wallow in the mud that is programming in lesser languages. So I continued to look down on Go and its users.
I have crossed paths with this book a number of times. I leafed through it, I even read the introduction, but I never picked it up properly. This changed because, of all things, a book on Zen Buddhism. You see, the book explained, us westerners are prone to dual thinking (thanks a bunch Plato and Aristotle). We like to think of things in clear cut categories (heh): black-white, good-bad, superior-inferior. Gradually, as I made my way through that book, I realised more and more that I'd been a victim of this dual way thinking myself! And what better way to step out of it than trying a language I had labeled as "bad", "inferior" and a bunch of other hasty cargo culted generalisations? So I ordered "The Go Programming Language" (GoPL).
Let me say it upfront: GoPL is a good technical book. This is how a book introducing a programming language should be written. It treats the reader as an adult (even more so, as an engineer!). Go is rooted in the Unix world, and the authors want you to know that, God dammit. It doesn't use cutesy examples with meme names for variables. The examples are very much the seeds of applications you would use in the real world (also known as "tools" in Unix parlance). The nature of the Buddha is continuous.
You can see this is a "Kernighan"--if we can use painters' names as nouns, we can use authors' names as nouns! The book's structure and exposition style echo those of "The C Programming Language" and "Software Tools (in Pascal)". The authors don't shy away from using programs they've written in earlier chapters to illustrate the behaviour of later programs. They even gasp compose them in shell pipelines. You see, the truth is GoPL also moonlights as a Unix philosophy book. And it does a great job at it. If you're so inclined, you'll learn more from this book than all the "do one thing and do it well" blog posts out there.
The examples are engaging. The first chapter is a whirlwind tour of Go and its standard library. And it's a very convincing one. It even has pictures of pretty 3d graphs. In the browser! Oh boy, tell me more about this Go thing you're talking about. The rest of the chapters treat one topic at a time. Most of the times in depth. The final chapter, the one on unsafe programming, is a glimpse of the dark world of juggling with chainsaws. And an admonishment to not do so lightly. The authors even have the audacity to lightly bash C. You can't run from your past Mr. Kernighan!
And I can't be sure, but I think the authors were reading my mind, because whenever I had a question, the answer was close by--in the next paragraph or the next page. Seriously, it's a well organised book.
One thing I appreciate is that the authors are honest when they take shortcuts (lack of error checking, brittle practices) in order to save space. If only all programmers would be this honest.
But this review is getting long, and a mercenary's day is busy. Glue code doesn't write itself. So, should you read this book? The answer depends on what you're looking for.
Do you want to learn Go? What are you waiting for? Go for it!
Do you want to write an introductory book for you own language or favourite language? Steal this book!
Do you find Go uninteresting, but you're one of those weirdos who reads technical books just because? Give it a go. You might even change you opinion about the language by the end of it.
Do you want to dine with the gods from the ambrosia of pure abstraction? I'm afraid you're out of luck. But hey, at least you'll get a taste of what passes as programming amongst us, the unwashed masses.