Book description
Go is an increasingly popular language for programming everything from web applications to distributed network services. This practical guide provides recipes to help you unravel common problems and perform useful tasks when working with Go. Each recipe includes self-contained code solutions that you can freely use, along with a discussion of how and why they work. Programmers new to Go can quickly ramp up their knowledge while accomplishing useful tasks, and experienced Go developers can save time by cutting and pasting proven code directly into their applications.
Recipes include:
- Creating a module
- Calling code from another module
- Returning and handling an error
- Converting strings to numbers (or converting numbers to strings)
- Modifying multiple characters in a string
- Creating substrings from a string
- Capturing string input
- And so much more
Publisher resources
Table of contents
- Preface
- 1. Getting Started Recipes
-
2. Module Recipes
- 2.0. Introduction
- 2.1. Creating a Go Module
- 2.2. Importing Dependent Packages Into Your Module
- 2.3. Removing Dependent Packages from Your Module
- 2.4. Find Available Versions of Third-Party Packages
- 2.5. Importing a Specific Version of a Dependent Package Into Your Module
- 2.6. Requiring Local Versions of Dependent Packages
- 2.7. Using Multiple Versions of the Same Dependent Packages
- 3. Error Handling Recipes
- 4. Logging Recipes
- 5. Function Recipes
-
6. String Recipes
- 6.0. Introduction
- 6.1. Creating Strings
- 6.2. Converting String to Bytes and Bytes to String
- 6.3. Creating Strings from Other Strings and Data
- 6.4. Converting Strings to Numbers
- 6.5. Converting Numbers to Strings
- 6.6. Replacing Multiple Characters in a String
- 6.7. Creating a Substring from a String
- 6.8. Checking if a String Contains Another String
- 6.9. Splitting a String Into an Array of Strings or Combining an Array of Strings Into a String
- 6.10. Trimming Strings
- 6.11. Capturing String Input from the Command Line
- 6.12. Escaping and Unescaping HTML Strings
- 6.13. Using Regular Expressions
- 7. General Input/Output Recipes
- 8. CSV Recipes
- 9. JSON Recipes
- 10. Binary Recipes
- 11. Date and Time Recipes
- 12. Structs Recipes
- 13. Data Structure Recipes
- 14. More Data Structure Recipes
- 15. Image-Processing Recipes
- 16. Networking Recipes
-
17. Web Recipes
- 17.0. Introduction
- 17.1. Creating a Simple Web Application
- 17.2. Handling HTTP Requests
- 17.3. Handling HTML Forms
- 17.4. Uploading a File to a Web Application
- 17.5. Serving Static Files
- 17.6. Creating a JSON Web Service API
- 17.7. Serving Through HTTPS
- 17.8. Using Templates for Go Web Applications
- 17.9. Making an HTTP Client Request
-
18. Testing Recipes
- 18.0. Introduction
- 18.1. Automating Functional Tests
- 18.2. Running Multiple Test Cases
- 18.3. Setting Up and Tearing Down Before and After Tests
- 18.4. Creating Subtests to Have Finer Control Over Groups of Test Cases
- 18.5. Running Tests in Parallel
- 18.6. Generating Random Test Inputs for Tests
- 18.7. Measuring Test Coverage
- 18.8. Testing a Web Application or a Web Service
-
19. Benchmarking Recipes
- 19.0. Introduction
- 19.1. Automating Performance Tests
- 19.2. Running Only Performance Tests
- 19.3. Avoiding Test Fixtures in Performance Tests
- 19.4. Changing the Timing for Running Performance Tests
- 19.5. Running Multiple Performance Test Cases
- 19.6. Comparing Performance Test Results
- 19.7. Profiling a Program
- Index
- About the Author
Product information
- Title: Go Cookbook
- Author(s):
- Release date: September 2023
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781098122119
You might also like
book
Go Cookbook
Bridge the gap between basic understanding of Go and use of its advanced features About This …
book
GitOps Cookbook
Why are so many companies adopting GitOps for their DevOps and cloud native strategy? This reliable …
book
Go in Action
Go in Action introduces the Go language, guiding you from inquisitive developer to Go guru. The …
book
Terraform Cookbook
Cloud services and SaaS software permeate every company's IT landscape, requiring a shift from manually provisioned …