Go in 24 Hours, Sams Teach Yourself: Next Generation Systems Programming with Golang, First Edition

Book description

In just 24 sessions of one hour or less, Sams Teach Yourself Go in 24 Hours will help new and experienced programmers build software that’s simpler, more reliable, and far more scalable. This book’s straightforward, step-by-step approach guides you from setting up your environment through testing and deploying powerful solutions. Using practical examples, expert Go developer George Ornbo walks you through Go’s fundamental constructs, demonstrates its breakthrough features for concurrent and network programming, and illuminates Go’s powerful new idioms. Every lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success.

 

Step-by-step instructions carefully walk you through the most common Go programming tasks and techniques

Quizzes and exercises help you test your knowledge and stretch your skills

Practical, hands-on examples show you how to apply what you learn

Notes and Tips point out shortcuts, solutions, and problems to avoid

Two bonus chapters available online: Hour 25, “Creating a RESTful JSON API,” and Hour 26 “Creating a TCP Chat Server”

 

Learn how to…

· Get productive quickly with Go development tools and web servers

· Master core features, including strings, functions, structs, and methods

· Work with types, variables, functions, and control structures

· Make the most of Go’s arrays, slices, and maps

· Write powerful concurrent software with Goroutines and channels

· Handle program errors smoothly

· Promote code reuse with packages

· Master Go’s unique idioms for highly effective coding

· Use regular expressions and time/date functions

· Test and benchmark Go code

· Write basic command-line programs, HTTP servers, and HTTP clients

· Efficiently move Go code into production

· Build basic TCP chat servers and JSON APIs

Register your book at informit.com/register for convenient access to the two bonus chapters online, downloads, updates, and/or corrections as they become available.

Table of contents

  1. Cover Page
  2. About This E-Book
  3. Title Page
  4. Copyright Page
  5. Contents at a Glance
  6. Table of Contents
  7. About the Author
  8. Dedication
  9. Acknowledgments
  10. We Want to Hear from You!
  11. Reader Services
  12. Introduction
    1. Who Should Read This Book?
    2. Why Should I Learn Go?
    3. How This Book Is Organized
    4. Code Examples
  13. Hour 1. Getting Started
    1. Introducing Go
      1. History of Go
      2. Go Is a Compiled Language
    2. Installing Go
      1. Installing on Windows
      2. Installing on macOS or Linux
    3. Setting Up Your Environment
    4. Writing Your First Go Program: Hello World
      1. Compiling and Running Programs with Go Run
      2. Meet the Gopher
    5. Summary
    6. Q&A
    7. Workshop
      1. Quiz
      2. Answers
    8. Exercises
  14. Hour 2. Understanding Types
    1. What Is a Data Type?
    2. Differentiating Between Static and Dynamic Typing
    3. Implementing Booleans
    4. Understanding Numeric Types
      1. Signed and Unsigned Integers
      2. Floats
      3. Strings
      4. Arrays
    5. Checking the Type of a Variable
    6. Converting Between Types
    7. Summary
    8. Q&A
    9. Workshop
      1. Quiz
      2. Answers
    10. Exercises
  15. Hour 3. Understanding Variables
    1. What Is a Variable?
    2. Declaring Shorthand Variables
    3. Understanding Variables and Zero Values
    4. Writing a Short Variable Declaration
    5. Styles of Variable Declaration
    6. Using Variable Scope
    7. Using Pointers
    8. Declaring Variables with Constants
    9. Summary
    10. Q&A
    11. Workshop
      1. Quiz
      2. Answers
    12. Exercises
  16. Hour 4. Using Functions in Go
    1. What Is a Function?
      1. Function Structure
      2. Returning a Single Result
      3. Returning Multiple Values
    2. Defining Variadic Functions
    3. Using Named Return Values
    4. Using Recursive Functions
    5. Passing Functions as Values
    6. Summary
    7. Q&A
    8. Workshop
      1. Quiz
      2. Answers
    9. Exercises
  17. Hour 5. Using Control Flow
    1. Using the if Statement
    2. Using the else Statement
    3. Using the else if Statement
    4. Using Comparison Operators
    5. Using Arithmetic Operators
    6. Using Logical Operators
    7. Using the switch Statement
    8. Looping with the for Statement
      1. A for Statement with init and post Statements
      2. for Statements with a range Clause
    9. Using the defer Statement
    10. Summary
    11. Q&A
    12. Workshop
      1. Quiz
      2. Answers
    13. Exercises
  18. Hour 6. Working with Arrays, Slices, and Maps
    1. Working with Arrays
    2. Working with Slices
      1. Adding Elements to a Slice
      2. Deleting Elements from a Slice
      3. Copying Elements from a Slice
    3. Working with Maps
      1. Deleting Elements from a Map
    4. Summary
    5. Q&A
    6. Workshop
      1. Quiz
      2. Answers
    7. Exercises
  19. Hour 7. Using Structs and Pointers
    1. What Is a Struct?
    2. Initializing a Struct
    3. Nesting Structs
    4. Creating Default Values for Structs
    5. Comparing Structs
    6. Understanding Public and Private Values
    7. Differentiating Between Pointer and Value References
    8. Summary
    9. Q&A
    10. Workshop
      1. Quiz
      2. Answers
    11. Exercises
  20. Hour 8. Creating Methods and Interfaces
    1. Using Methods
    2. Creating Method Sets
    3. Working with Methods and Pointers
    4. Using Interfaces
    5. Summary
    6. Q&A
    7. Workshop
      1. Quiz
      2. Answers
    8. Exercises
  21. Hour 9. Working with Strings
    1. Creating String Literals
    2. Understanding Rune Literals
    3. Concatenating Strings
      1. Concatenating Strings with a Buffer
      2. Understanding What a String Is
      3. Working with Strings
    4. Summary
    5. Q&A
    6. Workshop
      1. Quiz
      2. Answers
    7. Exercises
  22. Hour 10. Handling Errors
    1. Handling Errors and Idiomatic Go
    2. Understanding the Error Type
    3. Creating Errors
    4. Formatting Errors
    5. Returning an Error from a Function
    6. Errors and Usability
    7. Don’t panic
    8. Summary
    9. Q&A
    10. Workshop
      1. Quiz
      2. Answers
    11. Exercises
  23. Hour 11. Working with Goroutines
    1. Understanding Concurrency
    2. Concurrency Versus Parallelism
    3. Understanding Concurrency Through a Web Browser
    4. Blocking and Non-Blocking Code
    5. Handling Concurrent Operations with Goroutines
    6. Using Goroutines to Manage Latency
    7. Defining Goroutines
    8. Summary
    9. Q&A
    10. Workshop
      1. Quiz
      2. Answers
    11. Exercises
  24. Hour 12. Introducing Channels
    1. Using Channels
    2. Using Buffered Channels
    3. Blocking and Flow Control
    4. Using Channels as Function Arguments
    5. Employing the select Statement
    6. Quitting Channels
    7. Summary
    8. Q&A
    9. Workshop
      1. Quiz
      2. Answers
    10. Exercises
  25. Hour 13. Using Packages for Code Reuse
    1. Importing Packages
    2. Understanding Package Usage
    3. Using Third-Party Packages
    4. Installing a Third-Party Package
    5. Managing Third-Party Dependencies
      1. Creating a Package
    6. Summary
    7. Q&A
    8. Workshop
      1. Quiz
      2. Answers
    9. Exercises
  26. Hour 14. Naming Conventions in Go
    1. Formatting Code in Go
    2. Using gofmt
    3. Configuring Text Editors
    4. Naming Conventions
    5. Using golint
    6. Using godoc
    7. Automating Workflow
    8. Summary
    9. Q&A
    10. Workshop
      1. Quiz
      2. Answers
    11. Exercises
  27. Hour 15. Testing and Performance
    1. Testing: The Most Important Aspect of Software Development
      1. Unit Tests
      2. Integration Tests
      3. Functional Tests
      4. Test-Driven Development
    2. testing Package
    3. Running Table Tests
    4. Benchmarking in Go
    5. Providing Test Coverage
    6. Summary
    7. Q&A
    8. Workshop
      1. Quiz
      2. Answers
    9. Exercises
  28. Hour 16. Debugging
    1. Logging
    2. Printing Data
    3. Using the fmt Package
    4. Using Delve
    5. Using gdb
    6. Summary
    7. Q&A
    8. Workshop
      1. Quiz
      2. Answers
    9. Exercises
  29. Hour 17. Using Command-Line Programs
    1. Operating with Inputs and Outputs
    2. Accessing Raw Command-Line Arguments
    3. Parsing Command-Line Flags
    4. Working with Types
    5. Customizing Help Text
    6. Creating Subcommands
    7. POSIX Compliance
    8. Installing and Sharing Command-Line Programs
    9. Summary
    10. Q&A
    11. Workshop
      1. Quiz
      2. Answers
    12. Exercises
  30. Hour 18. Creating HTTP Servers
    1. Announcing Your Presence with the “Hello World” Web Server
    2. Examining Requests and Responses
      1. Making a Request with curl
      2. Routing in More Detail
    3. Working with Handler Functions
    4. Handling 404s
    5. Setting a Header
      1. Responding with Different Content Types
    6. Responding to Different Types of Requests
    7. Receiving Data from GET and POST Requests
    8. Summary
    9. Q&A
    10. Workshop
      1. Quiz
      2. Answers
    11. Exercises
  31. Hour 19. Creating HTTP Clients with Go
    1. Understanding HTTP
    2. Making a GET Request
    3. Making a POST Request
    4. Gaining Further Control over HTTP Requests
    5. Debugging HTTP Requests
    6. Dealing with Timeouts
    7. Summary
    8. Q&A
    9. Workshop
      1. Quiz
      2. Answers
    10. Exercises
  32. Hour 20. Working with JSON
    1. Introducing JSON
    2. Using JSON APIs
    3. Using JSON with Go
    4. Decoding JSON
    5. Mapping Data Types
    6. Working with JSON Received over HTTP
    7. Summary
    8. Q&A
    9. Workshop
      1. Quiz
      2. Answers
    10. Exercises
  33. Hour 21. Working with Files
    1. Importance of Files
    2. Reading and Writing Files with the ioutil Package
      1. Reading a File
      2. Creating a File
    3. Writing to a File
    4. Listing a Directory
    5. Copying a File
    6. Deleting Files
    7. Using Files to Manage Configuration
      1. Using JSON Files
      2. Using TOML Files
    8. Summary
    9. Q&A
    10. Workshop
      1. Quiz
      2. Answers
    11. Exercises
  34. Hour 22. Introducing Regular Expressions
    1. Defining Regular Expressions
    2. Getting Familiar with Regular Expression Syntax
    3. Using Regular Expressions for Validation
    4. Using Regular Expressions to Transform Data
    5. Parsing Data with Regular Expressions
    6. Summary
    7. Q&A
    8. Workshop
      1. Quiz
      2. Answers
    9. Exercises
  35. Hour 23. Programming Time in Go
    1. Programming the Element of Time
    2. Putting Your Program to Sleep
    3. Setting a Timeout
    4. Using a Ticker
    5. Representing Time in a String Format
    6. Working with Time Structs
    7. Adding and Subtracting Time
    8. Comparing Different Time Structs
    9. Summary
    10. Q&A
    11. Workshop
      1. Quiz
      2. Answers
    12. Exercises
  36. Hour 24. Deploying Go Code
    1. Understanding Targets
    2. Reducing the Size of Binaries
    3. Using Docker
    4. Downloading Binary Files
    5. Using go get
    6. Releasing Code with Package Managers
    7. Summary
    8. Q&A
    9. Workshop
      1. Quiz
      2. Answers
    10. Exercises
  37. Index
  38. Hour 25. Creating a RESTful JSON API
    1. Managing Dependencies with dep
    2. Creating an HTTP Server
    3. Creating Routes for a REST API
    4. Testing HTTP Routes
    5. Serving JSON
    6. Adding Data Persistence
    7. Summary
    8. Q&A
    9. Workshop
      1. Quiz
      2. Answers
    10. Exercises
  39. Hour 26. Creating a TCP Chat Server
    1. What Is TCP?
    2. Using telnet
    3. Using the net Package
    4. Creating a Simple Chat Server
    5. Managing Client Connections
    6. Enabling Messaging Between Clients
    7. Preventing Echoes
    8. Summary
    9. Q&A
    10. Workshop
      1. Quiz
      2. Answers
    11. Exercises
  40. Code Snippets

Product information

  • Title: Go in 24 Hours, Sams Teach Yourself: Next Generation Systems Programming with Golang, First Edition
  • Author(s): George Ornbo
  • Release date: December 2017
  • Publisher(s): Sams
  • ISBN: 9780134771922