Book description
Publisher's Note: This edition from 2019 is outdated and is not compatible with the latest version of Go. A new third edition, updated for 2021 and featuring the latest in Go programming, has now been published.
Key Features
- Second edition of the bestselling guide to advanced Go programming, expanded to cover machine learning, more Go packages and a range of modern development techniques
- Completes the Go developer's education with real-world guides to building high-performance production systems
- Packed with practical examples and patterns to apply to your own development work
- Clearly explains Go nuances and features to remove the frustration from Go development
Book Description
Often referred to (incorrectly) as Golang, Go is the high-performance systems language of the future. Mastering Go, Second Edition helps you become a productive expert Go programmer, building and improving on the groundbreaking first edition.
Mastering Go, Second Edition shows how to put Go to work on real production systems. For programmers who already know the Go language basics, this book provides examples, patterns, and clear explanations to help you deeply understand Go's capabilities and apply them in your programming work.
The book covers the nuances of Go, with in-depth guides on types and structures, packages, concurrency, network programming, compiler design, optimization, and more. Each chapter ends with exercises and resources to fully embed your new knowledge.
This second edition includes a completely new chapter on machine learning in Go, guiding you from the foundation statistics techniques through simple regression and clustering to classification, neural networks, and anomaly detection. Other chapters are expanded to cover using Go with Docker and Kubernetes, Git, WebAssembly, JSON, and more.
If you take the Go programming language seriously, the second edition of this book is an essential guide on expert techniques.
What you will learn
- Clear guidance on using Go for production systems
- Detailed explanations of how Go internals work, the design choices behind the language, and how to optimize your Go code
- A full guide to all Go data types, composite types, and data structures
- Master packages, reflection, and interfaces for effective Go programming
- Build high-performance systems networking code, including server and client-side applications
- Interface with other systems using WebAssembly, JSON, and gRPC
- Write reliable, high-performance concurrent code
- Build machine learning systems in Go, from simple statistical regression to complex neural networks
Who this book is for
Mastering Go, Second Edition is for Go programmers who already know the language basics, and want to become expert Go practitioners.
Table of contents
- Title Page
- Copyright and Credits
- About Packt
- Contributors
- Preface
-
Go and the Operating System
- The history of Go
- Where is Go going?
- The advantages of Go
- Compiling Go code
- Executing Go code
- Two Go rules
- Downloading Go packages
- UNIX stdin, stdout, and stderr
- About printing output
- Using standard output
- Getting user input
- About error output
- Writing to log files
- Error handling in Go
- Using Docker
- Exercises and links
- Summary
-
Understanding Go Internals
- The Go compiler
- Garbage collection
- Calling C code from Go
- Calling Go functions from C code
- The defer keyword
- Panic and recover
- Two handy UNIX utilities
- Your Go environment
- The go env command
- The Go assembler
- Node trees
- Finding out more about go build
- Creating WebAssembly code
- General Go coding advice
- Exercises and links
- Summary
- Working with Basic Go Data Types
- The Uses of Composite Types
-
How to Enhance Go Code with Data Structures
- About graphs and nodes
- Algorithm complexity
- Binary trees in Go
- Hash tables in Go
- Linked lists in Go
- Doubly linked lists in Go
- Queues in Go
- Stacks in Go
- The container package
- Generating random numbers
- Generating secure random numbers
- Performing matrix calculations
- Solving Sudoku puzzles
- Additional resources
- Exercises
- Summary
-
What You Might Not Know About Go Packages and Functions
- About Go packages
- About Go functions
- Developing your own Go packages
- Go modules
- Creating good Go packages
- The syscall package
- The go/scanner, go/parser, and go/token packages
- Text and HTML templates
- Additional resources
- Exercises
- Summary
- Reflection and Interfaces for All Seasons
-
Telling a UNIX System What to Do
- About UNIX processes
- The flag package
- The viper package
- The cobra package
- The io.Reader and io.Writer Interfaces
- The bufio package
- Reading text files
- Reading a specific amount of data
- The advantages of binary formats
- Reading CSV files
- Writing to a file
- Loading and saving data on disk
- The strings package revisited
- About the bytes package
- File permissions
- Handling UNIX signals
- Programming UNIX pipes in Go
- About syscall.PtraceRegs
- Tracing system calls
- User ID and group ID
- The Docker API and Go
- Additional resources
- Exercises
- Summary
- Concurrency in Go – Goroutines, Channels, and Pipelines
- Concurrency in Go – Advanced Topics
-
Code Testing, Optimization, and Profiling
- About optimization
- Optimizing Go code
- Profiling Go code
- The go tool trace utility
- Testing Go code
- Testing an HTTP server with a database backend
- Benchmarking Go code
- A simple benchmarking example
- Benchmarking buffered writing
- Finding unreachable Go code
- Cross-compilation
- Creating example functions
- From Go code to machine code
- Generating documentation
- Using Docker images
- Additional resources
- Exercises
- Summary
-
The Foundations of Network Programming in Go
- About net/http, net, and http.RoundTripper
- About TCP/IP
- About IPv4 and IPv6
- The nc(1) command-line utility
- Reading the configuration of network interfaces
- Performing DNS lookups
- Creating a web server in Go
- HTTP tracing
- Creating a web client in Go
- Timing out HTTP connections
- The Wireshark and tshark tools
- gRPC and Go
- Additional resources
- Exercises
- Summary
- Network Programming – Building Your Own Servers and Clients
- Machine Learning in Go
- Other Books You May Enjoy
Product information
- Title: Mastering Go - Second Edition
- Author(s):
- Release date: August 2021
- Publisher(s): Packt Publishing
- ISBN: 9781838559335
You might also like
book
Mastering Go - Third Edition
Master key features of Go, including advanced concepts like concurrency and working with JSON, to create …
book
Go Programming Cookbook - Second Edition
Tackle the trickiest of problems in Go programming with this practical guide Key Features Develop applications …
book
Go Systems Programming
Learning the new system’s programming language for all Unix-type systems About This Book Learn how to …
book
Go Programming Blueprints - Second Edition
Build real-world, production-ready solutions in Go using cutting-edge technology and techniques About This Book Get up …