Book Description
Go was created by Robert Griesemer, Rob Pike, and Ken Thompson to be an expressive and efficient language for writing readable and robust programs. Since its announcement in 2009, users of traditional, compiled languages have found Go’s simplicity, high-quality libraries, and straightforward tools to be a refreshing change. Go has also been winning converts from users of dynamic languages—those who appreciate how its lightweight type system makes their code safer and faster.
The Go Programming Language is the authoritative resource for any programmer who wants to learn Go quickly and effectively. It assumes no prior knowledge of Go nor prior experience with any specific language, so it provides a solid foundation whether your previous experience is with JavaScript, Ruby, Python, Java, or C++. This guide will show you how to write efficient and idiomatic Go, making good use of its standard libraries to solve real-world problems.
The first chapter is a tutorial on the basic constructs of Go, introduced through example programs for file I/O and text processing, simple graphics, and web clients and servers.
Early chapters cover the structural elements of a Go program: its syntax, basic and composite data types, functions, and error handling. The examples illustrate many standard packages, how to create new ones, and how to build, test, and manage projects using the go tool.
The chapters on methods and interfaces introduce Go’s unusual approach to object-oriented programming, including the key principles of encapsulation and composition, as well as Go’s distinctive notion of implicitly satisfied interfaces.
Two chapters on concurrency present in-depth approaches to this important topic. The first covers the basic mechanisms of goroutines and channels and the style of communicating sequential processes for which Go is renowned. The second covers more traditional aspects of using concurrency with shared variables. These chapters assume no prior knowledge of concurrency, so they provide an excellent tutorial for programmers who would like to understand it better.
The final two chapters explore lower-level features of Go. One covers the art of metaprogramming using reflection. The other shows how to use the unsafe package to step outside the type system in a controlled way for special situations, and how to use the cgo tool to create Go bindings for C libraries.
The book features hundreds of interesting and practical examples of idiomatic Go code that cover the whole language, its most important libraries, and a wide range of applications. Source code will be freely available for download from the book's companion website (upon publication) and may be conveniently fetched, built, and installed using the go get command.