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.
Table of contents
- Contents
- Preface
- 1. Tutorial
- 2. Program Structure
- 3. Basic Data Types
- 4. Composite Types
- 5. Functions
- 6. Methods
-
7. Interfaces
- 7.1 Interfaces as Contracts
- 7.2 Interface Types
- 7.3 Interface Satisfaction
- 7.4 Parsing Flags with flag.Value
- 7.5 Interface Values
- 7.6 Sorting with sort.Interface
- 7.7 The http.Handler Interface
- 7.8 The error Interface
- 7.9 Example: Expression Evaluator
- 7.10 Type Assertions
- 7.11 Discriminating Errors with Type Assertions
- 7.12 Querying Behaviors with Interface Type Assertions
- 7.13 Type Switches
- 7.14 Example: Token-Based XML Decoding
- 7.15 A Few Words of Advice
- 8. Goroutines and Channels
- 9. Concurrency with Shared Variables
- 10. Packages and the Go Tool
- 11. Testing
-
12. Reflection
- 12.1 Why Reflection?
- 12.2 reflect.Type and reflect.Value
- 12.3 Display, a Recursive Value Printer
- 12.4 Example: Encoding S-Expressions
- 12.5 Setting Variables with reflect.Value
- 12.6 Example: Decoding S-Expressions
- 12.7 Accessing Struct Field Tags
- 12.8 Displaying the Methods of a Type
- 12.9 A Word of Caution
- 13. Low-Level Programming
- Index
Product information
- Title: The Go Programming Language
- Author(s):
- Release date: October 2015
- Publisher(s): Addison-Wesley Professional
- ISBN: 9780134190570
You might also like
book
The Rust Programming Language, 2nd Edition
The Rust Programming Language, 2nd Edition is the official guide to Rust 2021: an open source …
book
Programming Rust, 2nd Edition
Systems programming provides the foundation for the world's computation. Writing performance-sensitive code requires a programming language …
video
Ultimate Go Programming, Second Edition
An updated edition of this video title is available. Please go to Ultimate Go: Advanced Concepts …
book
Pro Go: The Complete Guide to Programming Reliable and Efficient Software Using Golang
Best-selling author Adam Freeman explains how to get the most from Go, starting from the basics …