0%

Book Description

Go is rapidly becoming the preferred language for building web services. There are plenty of tutorials available that teach Go’s syntax to developers with experience in other programming languages. But tutorials aren’t enough. They don’t teach Go’s idioms, so developers end up recreating patterns that don’t make sense in a Go context. This practical guide provides the essential background you need to write clear and idiomatic Go.

No matter your level of experience, you'll learn how to think like a Go developer. Author Jon Bodner explains the rationale behind the Go team’s design decisions and reveals design patterns that experienced Go developers have adopted. You’ll learn how to structure your project and choose the proper tools and libraries to create successful software.

  • Learn how to write idiomatic code in Go and design a Go project
  • Understand the reasons for the design decisions in Go
  • Set up a Go development environment for a solo developer or team
  • Explore which libraries to select when solving problems
  • Learn how Go’s features allow the language to run efficiently
  • Know which Go features you should use sparingly, or not at all

Table of Contents

  1. Preface
    1. Who Should Read This Book
    2. Conventions Used in This Book
    3. Using Code Examples
    4. O’Reilly Online Learning
    5. How to Contact Us
  2. 1. Primitive Types and Declarations
    1. Built-in types
      1. The zero value
      2. Explicit Type Conversion
      3. Literals
      4. Booleans
      5. Numeric Types
      6. Complex types (you’re probably not going to use these)
    2. A Taste of Strings and Runes
    3. var vs :=
    4. using const
      1. Typed and untyped constants
    5. Unused variables
    6. Naming variables and constants
    7. Wrapping Up
  3. 2. Errors
    1. How to Handle Errors: The Basics
    2. Use Strings For Simple Errors
    3. Sentinel Errors
    4. Errors are Values
    5. Wrapping Errors
    6. Is and As
    7. Wrapping Errors with defer
    8. panic and recover
    9. Getting a stack trace from an error
    10. Wrapping Up
  4. 3. The Context
    1. What is the Context?
    2. Cancellation
    3. Timers
      1. Handling Context Cancellation in Your Own Code
    4. Values
    5. Wrapping Up
3.145.105.105