Synopses & Reviews
Go is an open-source programming language that makes it easy to build clean, reliable, and efficient software. It has been winning converts from dynamic language enthusiasts as well as users of traditional compiled languages. The former appreciate the robustness and efficiency that Go's lightweight type system brings to their code; the latter find Go's simplicity and fast tools a refreshing change. Thanks to its well-designed standard libraries and its excellent support for concurrent programming, Go is fast becoming the language of choice for distributed systems.
The Go Programming Language is the definitive book on Go for the working programmer. It assumes no prior knowledge of Go, nor any other specific programming language, so you'll find it an accessible guide whether you come from JavaScript, Ruby, Python, Java, or C++.
The book will quickly get you started using Go effectively from the beginning, and by the end, you will know how to use it well to write clear, idiomatic and efficient programs to solve real-world problems. You'll understand not just how to use its standard libraries, but how they work, and how to apply the same design techniques to your own projects.
The earlier chapters will introduce you to the basic concepts of Go programming---numbers, strings, functions---while at the same time presenting important computer science concepts like recursion, and useful examples of graphics, UTF-8, and error handling. The chapters on methods and interfaces will show you a new way to think about object-oriented programming; the chapter on concurrency explains why concurrency is so important in modern programming, and how Go helps you handle it well. You'll also learn about Go's pragmatic but effective approach to testing; how to build, test, and manage projects using the go tool, and the art of metaprogramming using reflection.
The book contains hundreds of interesting and practical examples that cover the whole language and a wide range of applications. The code samples from the book are available for download from gopl.io.
Synopsis
The Go Programming Language is the authoritative resource for any programmer who wants to learn Go. It shows how to write clear and idiomatic Go to solve real-world problems. The book does not assume prior knowledge of Go nor experience with any specific language, so you ll find it accessible whether you re most comfortable with JavaScript, Ruby, Python, Java, or C++.
- The first chapter is a tutorial on the basic concepts of Go, introduced through programs for file I/O and text processing, simple graphics, and web clients and servers.
- Early chapters cover the structural elements of Go programs: syntax, control flow, data types, and the organization of a program into packages, files, and functions. The examples illustrate many packages from the standard library and show how to create new ones of your own. Later chapters explain the package mechanism in more detail, and how to build, test, and maintain projects using the go tool.
- The chapters on methods and interfaces introduce Go s unconventional approach to object-oriented programming, in which methods can be declared on any type and interfaces are implicitly satisfied. They explain the key principles of encapsulation, composition, and substitutability using realistic examples.
- Two chapters on concurrency present in-depth approaches to this increasingly important topic. The first, which covers the basic mechanisms of goroutines and channels, illustrates the style known as communicating sequential processes for which Go is renowned. The second covers more traditional aspects of concurrency with shared variables. These chapters provide a solid foundation for programmers encountering concurrency for the first time.
- 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 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 well-written Go code that cover the whole language, its most important packages, and a wide range of applications. Each chapter has exercises to test your understanding and explore extensions and alternatives. Source code is freely available for download from http: //gopl.io/ and may be conveniently fetched, built, and installed using the go get command."
Synopsis
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.
Synopsis
About the Author
Alan Donovan is a Staff Engineer in Google's infrastructure division, specializing in software development tools. Since 2012, he has been working on the Go team, designing libraries and tools for static analysis. He is the author of `oracle`, `godoc -analysis`, `eg`, and `gorename`.
Brian Kernighan was in the Computing Science Research center at Bell Labs until 2000, where he worked on languages and tools for Unix. He is now a professor in the Computer Science Department at Princeton. He is the co-author of several books, including The C Programming Language and The Practice of Programming.
Table of Contents
1. Tutorial
2. Basic Types
3. Composite Types
4. Functions
5. Methods and Interfaces
6. Concurrency
7. Packages and the `go` tool
8. Testing
9. Reflection
10. Standard Packages
A. Reference Material