توضیحاتی در مورد کتاب Pro Go: The Complete Guide to Programming Reliable and Efficient Software Using Golang
نام کتاب : Pro Go: The Complete Guide to Programming Reliable and Efficient Software Using Golang
عنوان ترجمه شده به فارسی : Pro Go: راهنمای کامل برنامه نویسی نرم افزار قابل اعتماد و کارآمد با استفاده از Golang
سری :
نویسندگان : Adam Freeman
ناشر : Apress
سال نشر :
تعداد صفحات : 1078
ISBN (شابک) : 9781484273548 , 9781484273555
زبان کتاب : English
فرمت کتاب : pdf
حجم کتاب : 13 مگابایت
بعد از تکمیل فرایند پرداخت لینک دانلود کتاب ارائه خواهد شد. درصورت ثبت نام و ورود به حساب کاربری خود قادر خواهید بود لیست کتاب های خریداری شده را مشاهده فرمایید.
فهرست مطالب :
Table of Contents
About the Author
About the Technical Reviewer
Part I: Understanding the Go Language
Chapter 1: Your First Go Application
Setting the Scene
Installing the Development Tools
Installing Git
Selecting a Code Editor
Creating the Project
Defining a Data Type and a Collection
Creating HTML Templates
Loading the Templates
Creating the HTTP Handlers and Server
Writing the Form Handling Function
Handling the Form Data
Adding Data Validation
Summary
Chapter 2: Putting Go in Context
Why Should You Learn Go?
What’s the Catch?
Is It Really That Bad?
What Do You Need to Know?
What Is the Structure of This Book?
Part 1: Understanding the Go Language
Part 2: Using the Go Standard Library
Part 3: Applying Go
What Doesn’t This Book Cover?
What If You Find an Error in the Book?
Are There Lots of Examples?
What Software Do You Need for the Examples?
What Platforms Will the Examples Run On?
What If You Have Problems Following the Examples?
Where Can You Get the Example Code?
Why Do Some of the Examples Have Odd Formatting?
How Do I Contact the Author?
What If I Really Enjoyed This Book?
What If This Book Has Made Me Angry and I Want to Complain?
Summary
Chapter 3: Using the Go Tools
Using the Go Command
Creating a Go Project
Understanding the Package Declaration
Understanding the Import Statement
Understanding the Function
Understanding the Code Statement
Compiling and Running Source Code
Cleaning Up
Using the Go Run Command
Defining a Module
Debugging Go Code
Preparing for Debugging
Using the Debugger
Using a Delve Editor Plugin
Linting Go Code
Using the Linter
Disabling Linter Rules
Creating a Linter Configuration File
Fixing Common Problems in Go Code
Formatting Go Code
Summary
Chapter 4: Basic Types, Values, and Pointers
Preparing for This Chapter
Using the Go Standard Library
Understanding the Basic Data Types
Understanding Literal Values
Using Constants
Understanding Untyped Constants
Defining Multiple Constants with a Single Statement
Revisiting Literal Values
Using Variables
Omitting the Variable’s Data Type
Omitting the Variable’s Value Assignment
Defining Multiple Variables with a Single Statement
Using the Short Variable Declaration Syntax
Using the Short Variable Syntax to Redefine Variables
Using the Blank Identifier
Understanding Pointers
Defining a Pointer
Following a Pointer
Understanding Pointer Zero Values
Pointing at Pointers
Understanding Why Pointers Are Useful
Summary
Chapter 5: Operations and Conversions
Preparing for This Chapter
Understanding the Go Operators
Understanding the Arithmetic Operators
Understanding Arithmetic Overflow
Using the Remainder Operator
Using the Increment and Decrement Operators
Concatenating Strings
Understanding the Comparison Operators
Comparing Pointers
Understanding the Logical Operators
Converting, Parsing, and Formatting Values
Performing Explicit Type Conversions
Understanding the Limitations of Explicit Conversions
Converting Floating-Point Values to Integers
Parsing from Strings
Parsing Integers
Parsing Binary, Octal, and Hexadecimal Integers
Using the Integer Convenience Function
Parsing Floating-Point Numbers
Formatting Values as Strings
Formatting Boolean Values
Formatting Integer Values
Using the Integer Convenience Function
Formatting Floating-Point Values
Summary
Chapter 6: Flow Control
Preparing for This Chapter
Understanding Flow Control
Using if Statements
Using the else Keyword
Understanding if Statement Scope
Using an Initialization Statement with an if Statement
Using for Loops
Incorporating the Condition into the Loop
Using Initialization and Completion Statements
Continuing Loops
Enumerating Sequences
Receiving Only Indices or Values When Enumerating Sequences
Enumerating Built-in Data Structures
Using switch Statements
Matching Multiple Values
Terminate case Statement Execution
Forcing Falling Through to the Next case Statement
Providing a default Clause
Using an Initialization Statement
Omitting a Comparison Value
Using Label Statements
Summary
Chapter 7: Using Arrays, Slices, and Maps
Preparing for This Chapter
Working with Arrays
Using the Array Literal Syntax
Understanding Array Types
Understanding Array Values
Comparing Arrays
Enumerating Arrays
Working with Slices
Appending Elements to a Slice
Allocating Additional Slice Capacity
Appending One Slice to Another
Creating Slices from Existing Arrays
Appending Elements When Using Existing Arrays for Slices
Specifying Capacity When Creating a Slice from an Array
Creating Slices from Other Slices
Using the copy Function
Using the copy Function to Ensure Slice Array Separation
Understanding the Uninitialized Slice Pitfall
Specifying Ranges When Copying Slices
Copying Slices with Different Sizes
Deleting Slice Elements
Enumerating Slices
Sorting Slices
Comparing Slices
Getting the Array Underlying a Slice
Working with Maps
Using the Map Literal Syntax
Checking for Items in a Map
Removing Items from a Map
Enumerating the Contents of a Map
Enumerating a Map in Order
Understanding the Dual Nature of Strings
Converting a String to Runes
Enumerating Strings
Summary
Chapter 8: Defining and Using Functions
Preparing for This Chapter
Defining a Simple Function
Defining and Using Function Parameters
Omitting Parameter Types
Omitting Parameter Names
Defining Variadic Parameters
Dealing with No Arguments for a Variadic Parameter
Using Slices as Values for Variadic Parameters
Using Pointers as Function Parameters
Defining and Using Function Results
Returning Multiple Function Results
Using Multiple Results Instead of Multiple Meanings
Using Named Results
Using the Blank Identifier to Discard Results
Using the defer Keyword
Summary
Chapter 9: Using Function Types
Preparing for This Chapter
Understanding Function Types
Understanding Function Comparisons and the Zero Type
Using Functions as Arguments
Using Functions as Results
Creating Function Type Aliases
Using the Literal Function Syntax
Understanding Function Variable Scope
Using Functions Values Directly
Understanding Function Closure
Understanding Closure Evaluation
Forcing Early Evaluation
Closing on a Pointer to Prevent Early Evaluation
Summary
Chapter 10: Defining Structs
Preparing for This Chapter
Defining and Using a Struct
Creating Struct Values
Using a Struct Value
Partially Assigning Struct Values
Using Field Positions to Create Struct Values
Defining Embedded Fields
Comparing Struct Values
Converting Between Struct Types
Defining Anonymous Struct Types
Creating Arrays, Slices, and Maps Containing Struct Values
Understanding Structs and Pointers
Understanding the Struct Pointer Convenience Syntax
Understanding Pointers to Values
Understanding Struct Constructor Functions
Using Pointer Types for Struct Fields
Understanding Pointer Field Copying
Understanding Zero Value for Structs and Pointers to Structs
Summary
Chapter 11: Using Methods and Interfaces
Preparing for This Chapter
Defining and Using Methods
Defining Method Parameters and Results
Understanding Method Overloading
Understanding Pointer and Value Receivers
Defining Methods for Type Aliases
Putting Types and Methods in Separate Files
Defining and Using Interfaces
Defining an Interface
Implementing an Interface
Using an Interface
Using an Interface in a Function
Using an Interface for Struct Fields
Understanding the Effect of Pointer Method Receivers
Comparing Interface Values
Performing Type Assertions
Testing Before Performing a Type Assertion
Switching on Dynamic Types
Using the Empty Interface
Using the Empty Interface for Function Parameters
Summary
Chapter 12: Creating and Using Packages
Preparing for This Chapter
Understanding the Module File
Creating a Custom Package
Using a Custom Package
Understanding Package Access Control
Adding Code Files to Packages
Dealing with Package Name Conflicts
Using a Package Alias
Using a Dot Import
Creating Nested Packages
Using Package Initialization Functions
Importing a Package Only for Initialization Effects
Using External Packages
Managing External Packages
Summary
Chapter 13: Type and Interface Composition
Preparing for This Chapter
Understanding Type Composition
Defining the Base Type
Defining a Constructor
Composing Types
Creating a Chain of Nested Types
Using Multiple Nested Types in the Same Struct
Understanding When Promotion Cannot Be Performed
Understanding Promotion Ambiguity
Understanding Composition and Interfaces
Using Composition to Implement Interfaces
Understanding the Type Switch Limitation
Composing Interfaces
Summary
Chapter 14: Using Goroutines and Channels
Preparing for This Chapter
Understanding How Go Executes Code
Creating Additional Goroutines
Returning Results from Goroutines
Sending a Result Using a Channel
Receiving a Result Using a Channel
Working with Channels
Coordinating Channels
Using a Buffered Channel
Inspecting a Channel Buffer
Sending and Receiving an Unknown Number of Values
Closing a Channel
Enumerating Channel Values
Restricting Channel Direction
Restricting Channel Argument Direction
Using Select Statements
Receiving Without Blocking
Receiving from Multiple Channels
Sending Without Blocking
Sending to Multiple Channels
Summary
Chapter 15: Error Handling
Preparing for This Chapter
Dealing with Recoverable Errors
Generating Errors
Reporting Errors via Channels
Using the Error Convenience Functions
Dealing with Unrecoverable Errors
Recovering from Panics
Panicking After a Recovery
Recovering from Panics in Go Routines
Summary
Part II: Using the Go Standard Library
Chapter 16: String Processing and Regular Expressions
Preparing for This Chapter
Processing Strings
Comparing Strings
Converting String Case
Working with Character Case
Inspecting Strings
Inspecting Strings with Custom Functions
Manipulating Strings
Splitting Strings
Restricting the Number of Results
Splitting on Whitespace Characters
Splitting Using a Custom Function to Split Strings
Trimming Strings
Trimming Whitespace
Trimming Character Sets
Trimming Substrings
Trimming with Custom Functions
Altering Strings
Altering Strings with a Map Function
Using a String Replacer
Building and Generating Strings
Building Strings
Using Regular Expressions
Compiling and Reusing Patterns
Splitting Strings Using a Regular Expression
Using Subexpressions
Using Named Subexpressions
Replacing Substrings Using a Regular Expression
Replacing Matched Content with a Function
Summary
Chapter 17: Formatting and Scanning Strings
Preparing for This Chapter
Writing Strings
Formatting Strings
Understanding the Formatting Verbs
Using the General-Purpose Formatting Verbs
Controlling Struct Formatting
Using the Integer Formatting Verbs
Using the Floating-Point Formatting Verbs
Using the String and Character Formatting Verbs
Using the Boolean Formatting Verb
Using the Pointer Formatting Verb
Scanning Strings
Dealing with Newline Characters
Using a Different String Source
Using a Scanning Template
Summary
Chapter 18: Math Functions and Data Sorting
Preparing for This Chapter
Working with Numbers
Generating Random Numbers
Generating a Random Number Within a Specific Range
Shuffling Elements
Sorting Data
Sorting Number and String Slices
Searching Sorted Data
Sorting Custom Data Types
Sorting Using Different Fields
Specifying the Comparison Function
Summary
Chapter 19: Dates, Times, and Durations
Preparing for This Chapter
Working with Dates and Times
Representing Dates and Times
Formatting Times as Strings
Parsing Time Values from Strings
Using Predefined Date Layouts
Specifying a Parsing Location
Using the Local Location
Specifying Time Zones Directly
Manipulating Time Values
Representing Durations
Creating Durations Relative to a Time
Creating Durations from Strings
Using the Time Features for Goroutines and Channels
Putting a Goroutine to Sleep
Deferring Execution of a Function
Receiving Timed Notifications
Using Notifications as Timeouts in Select Statements
Stopping and Resetting Timers
Receiving Recurring Notifications
Summary
Chapter 20: Reading and Writing Data
Preparing for This Chapter
Understanding Readers and Writers
Understanding Readers
Understanding Writers
Using the Utility Functions for Readers and Writers
Using the Specialized Readers and Writers
Using Pipes
Improving the Example
Concatenating Multiple Readers
Combining Multiple Writers
Echoing Reads to a Writer
Limiting Read Data
Buffering Data
Using the Additional Buffered Reader Methods
Performing Buffered Writes
Formatting and Scanning with Readers and Writers
Scanning Values from a Reader
Writing Formatted Strings to a Writer
Using a Replacer with a Writer
Summary
Chapter 21: Working with JSON Data
Preparing for This Chapter
Reading and Writing JSON Data
Encoding JSON Data
Encoding Arrays and Slices
Encoding Maps
Encoding Structs
Understanding the Effect of Promotion in JSON in Encoding
Customizing the JSON Encoding of Structs
Omitting a Field
Omitting Unassigned Fields
Forcing Fields to be Encoded as Strings
Encoding Interfaces
Creating Completely Custom JSON Encodings
Decoding JSON Data
Decoding Number Values
Specifying Types for Decoding
Decoding Arrays
Decoding Maps
Decoding Structs
Disallowing Unused Keys
Using Struct Tags to Control Decoding
Creating Completely Custom JSON Decoders
Summary
Chapter 22: Working with Files
Preparing for This Chapter
Reading Files
Using the Read Convenience Function
Decoding the JSON Data
Using the File Struct to Read a File
Reading from a Specific Location
Writing to Files
Using the Write Convenience Function
Using the File Struct to Write to a File
Writing JSON Data to a File
Using the Convenience Functions to Create New Files
Working with File Paths
Managing Files and Directories
Exploring the File System
Determining Whether a File Exists
Locating Files Using a Pattern
Processing All Files in a Directory
Summary
Chapter 23: Using HTML and Text Templates
Preparing for This Chapter
Creating HTML Templates
Loading and Executing Templates
Loading Multiple Templates
Enumerating Loaded Templates
Looking Up a Specific Template
Understanding Template Actions
Inserting Data Values
Formatting Data Values
Chaining and Parenthesizing Template Expressions
Trimming Whitespace
Using Slices in Templates
Using the Built-in Slice Functions
Conditionally Executing Template Content
Using the Optional Conditional Actions
Creating Named Nested Templates
Defining Template Blocks
Defining Template Functions
Disabling Function Result Encoding
Providing Access to Standard Library Functions
Defining Template Variables
Using Template Variables in Range Actions
Creating Text Templates
Summary
Chapter 24: Creating HTTP Servers
Preparing for This Chapter
Creating a Simple HTTP Server
Creating the HTTP Listener and Handler
Inspecting the Request
Filtering Requests and Generating Responses
Using the Response Convenience Functions
Using the Convenience Routing Handler
Supporting HTTPS Requests
Redirecting HTTP Requests to HTTPS
Creating a Static HTTP Server
Creating the Static File Route
Using Templates to Generate Responses
Responding with JSON Data
Handling Form Data
Reading Form Data from Requests
Reading Multipart Forms
Receiving Multiple Files in the Form
Reading and Setting Cookies
Summary
Chapter 25: Creating HTTP Clients
Preparing for This Chapter
Sending Simple HTTP Requests
Sending POST Requests
Posting a Form Using a Reader
Configuring HTTP Client Requests
Using the Convenience Functions to Create a Request
Working with Cookies
Creating Separate Clients and Cookie Jars
Managing Redirections
Creating Multipart Forms
Summary
Chapter 26: Working with Databases
Preparing for This Chapter
Preparing the Database
Installing a Database Driver
Opening a Database
Executing Statements and Queries
Querying for Multiple Rows
Understanding the Scan Method
Understanding the How SQL Values Can Be Scanned
Scanning Values into a Struct
Executing Statements with Placeholders
Executing Queries for Single Rows
Executing Other Queries
Using Prepared Statements
Using Transactions
Using Reflection to Scan Data into a Struct
Summary
Chapter 27: Using Reflection
Preparing for This Chapter
Understanding the Need for Reflection
Using Reflection
Using the Basic Type Features
Using the Basic Value Features
Identifying Types
Identifying Byte Slices
Obtaining Underlying Values
Setting a Value Using Reflection
Setting One Value Using Another
Comparing Values
Using the Comparison Convenience Function
Converting Values
Converting Numeric Types
Creating New Values
Summary
Chapter 28: Using Reflection, Part 2
Preparing for This Chapter
Working with Pointers
Working with Pointer Values
Working with Array and Slice Types
Working with Array and Slice Values
Enumerating Slices and Arrays
Creating New Slices from Existing Slices
Creating, Copying, and Appending Elements to Slices
Working with Map Types
Working with Map Values
Setting and Removing Map Values
Creating New Maps
Working with Struct Types
Processing Nested Fields
Locating a Field by Name
Inspecting Struct Tags
Creating Struct Types
Working with Struct Values
Setting Struct Field Values
Summary
Chapter 29: Using Reflection, Part 3
Preparing for This Chapter
Working with Function Types
Working with Function Values
Creating and Invoking New Function Types and Values
Working with Methods
Invoking Methods
Working with Interfaces
Getting Underlying Values from Interfaces
Examining Interface Methods
Working with Channel Types
Working with Channel Values
Creating New Channel Types and Values
Selecting from Multiple Channels
Summary
Chapter 30: Coordinating Goroutines
Preparing for This Chapter
Using Wait Groups
Using Mutual Exclusion
Using a Read-Write Mutex
Using Conditions to Coordinate Goroutines
Ensuring a Function Is Executed Once
Using Contexts
Canceling a Request
Setting a Deadline
Providing Request Data
Summary
Chapter 31: Unit Testing, Benchmarking, and Logging
Preparing for This Chapter
Using Testing
Running Unit Tests
Running Specific Tests
Managing Test Execution
Skipping Tests
Benchmarking Code
Removing Setup from the Benchmark
Performing Sub-benchmarks
Logging Data
Creating Custom Loggers
Summary
Part III: Applying Go
Chapter 32: Creating a Web Platform
Creating the Project
Creating Some Basic Platform Features
Creating the Logging System
Creating the Configuration System
Defining the Configuration File
Implementing the Configuration Interface
Using the Configuration System
Managing Services with Dependency Injection
Defining Service Lifecycles
Defining the Internal Service Functions
Defining the Service Registration Functions
Defining the Service Resolution Functions
Registering and Using Services
Adding Support for Invoking Functions
Adding Support for Resolving Struct Fields
Summary
Chapter 33: Middleware, Templates, and Handlers
Creating the Request Pipeline
Defining the Middleware Component Interface
Creating the Request Pipeline
Creating Basic Components
Creating the Services Middleware Component
Creating a Logging Middleware Component
Creating the Error Handling Component
Creating the Static File Component
Creating the Placeholder Response Component
Creating the HTTP Server
Configuring the Application
Streamlining Service Resolution
Creating HTML Responses
Creating the Layout and Template
Implementing Template Execution
Creating and Using the Template Service
Introducing Request Handlers
Generating URL Routes
Preparing Parameter Values for a Handler Method
Matching Requests to Routes
Summary
Chapter 34: Actions, Sessions, and Authorization
Introducing Action Results
Defining Common Action Results
Updating the Placeholders to Use Action Results
Invoking Request Handlers from Within Templates
Updating Request Handling
Configuring the Application
Generating URLs from Routes
Creating the URL Generator Service
Defining Alias Routes
Validating Request Data
Performing Data Validation
Adding Sessions
Delaying Writing Response Data
Creating the Session Interface, Service, and Middleware
Creating a Handler That Uses Sessions
Configuring the Application
Adding User Authorization
Defining the Basic Authorization Types
Implementing the Platform Interfaces
Implementing Access Controls
Implementing the Application Placeholder Features
Creating the Authentication Handler
Configuring the Application
Summary
Chapter 35: SportsStore: A Real Application
Creating the SportsStore Project
Configuring the Application
Starting the Data Model
Defining the Repository Interface
Implementing the (Temporary) Repository
Displaying a List of Products
Creating the Template and Layout
Configuring the Application
Adding Pagination
Styling the Template Content
Installing the Bootstrap CSS File
Updating the Layout
Styling the Template Content
Adding Support for Category Filtering
Updating the Request Handler
Creating the Category Handler
Displaying Category Navigation in the Product List Template
Registering the Handler and Updating the Aliases
Summary
Chapter 36: SportsStore: Cart and Database
Building the Shopping Cart
Defining the Cart Model and Repository
Creating the Cart Request Handler
Adding Products to the Cart
Configuring the Application
Adding the Cart Summary Widget
Invoking the Handler and Adding the CSS Icon Stylesheet
Using a Database Repository
Creating the Repository Types
Opening the Database and Loading the SQL Commands
Defining the Seed and Initialization Statements
Defining the Basic Queries
Defining the SQL Files for the Basic Queries
Defining the Paged Queries
Defining the SQL Repository Service
Configuring the Application to Use the SQL Repository
Summary
Chapter 37: SportsStore: Checkout and Administration
Creating the Checkout Process
Defining the Model
Extending the Repository
Disabling the Temporary Repository
Defining the Repository Methods and Commands
Defining the SQL Files
Implementing the Repository Methods
Creating the Request Handler and Templates
Integrating the Checkout Process
Registering the Request Handler
Creating Administration Features
Creating the Product Administration Feature
Extending the Repository
Implementing the Products Request Handler
Creating the Categories Administration Feature
Extending the Repository
Implementing the Category Request Handler
Summary
Chapter 38: SportsStore: Finishing and Deployment
Completing the Administration Features
Extending the Repository
Implementing the Request Handlers
Creating the Templates
Restricting Access to the Administration Features
Creating the User Store and Request Handler
Configuring the Application
Creating a Web Service
Preparing for Deployment
Installing the Certificates
Configuring the Application
Building the Application
Installing Docker Desktop
Creating the Docker Configuration Files
Summary
Index