About the Author |
|
xxvii | |
About the Technical Reviewer |
|
xxix | |
|
Part I Understanding the Go Language |
|
|
1 | (410) |
|
Chapter 1 Your First Go Application |
|
|
3 | (24) |
|
|
3 | (1) |
|
Installing the Development Tools |
|
|
3 | (1) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
5 | (1) |
|
Defining a Data Type and a Collection |
|
|
6 | (2) |
|
|
8 | (3) |
|
|
11 | (4) |
|
Creating the HTTP Handlers and Server |
|
|
15 | (3) |
|
Writing the Form Handling Function |
|
|
18 | (4) |
|
|
22 | (1) |
|
|
23 | (2) |
|
|
25 | (2) |
|
Chapter 2 Putting Go in Context |
|
|
27 | (8) |
|
|
27 | (1) |
|
|
27 | (1) |
|
|
28 | (1) |
|
What Do You Need to Know? |
|
|
28 | (1) |
|
What Is the Structure of This Book? |
|
|
28 | (1) |
|
Part 1 Understanding the Go Language |
|
|
28 | (1) |
|
Part 2 Using the Go Standard Library |
|
|
28 | (1) |
|
|
28 | (1) |
|
What Doesn't This Book Cover? |
|
|
28 | (1) |
|
What If You Find an Error in the Book? |
|
|
29 | (1) |
|
Are There Lots of Examples? |
|
|
29 | (2) |
|
What Software Do You Need for the Examples? |
|
|
31 | (1) |
|
What Platforms Will the Examples Run On? |
|
|
31 | (1) |
|
What If You Have Problems Following the Examples? |
|
|
31 | (1) |
|
Where Can You Get the Example Code? |
|
|
32 | (1) |
|
Why Do Some of the Examples Have Odd Formatting? |
|
|
32 | (1) |
|
How Do I Contact the Author? |
|
|
32 | (1) |
|
What If I Really Enjoyed This Book? |
|
|
32 | (1) |
|
What If This Book Has Made Me Angry and I Want to Complain? |
|
|
32 | (1) |
|
|
33 | (2) |
|
Chapter 3 Using the Go Tools |
|
|
35 | (24) |
|
|
35 | (1) |
|
|
36 | (1) |
|
Understanding the Package Declaration |
|
|
37 | (1) |
|
Understanding the Import Statement |
|
|
37 | (1) |
|
Understanding the Function |
|
|
38 | (1) |
|
Understanding the Code Statement |
|
|
38 | (2) |
|
Compiling and Running Source Code |
|
|
40 | (1) |
|
|
41 | (1) |
|
|
41 | (1) |
|
|
41 | (1) |
|
|
42 | (1) |
|
|
43 | (1) |
|
|
44 | (2) |
|
Using a Delve Editor Plugin |
|
|
46 | (1) |
|
|
47 | (1) |
|
|
48 | (2) |
|
|
50 | (3) |
|
Fixing Common Problems in Go Code |
|
|
53 | (3) |
|
|
56 | (1) |
|
|
57 | (2) |
|
Chapter 4 Basic Types, Values, and Pointers |
|
|
59 | (30) |
|
Preparing for This Chapter |
|
|
60 | (1) |
|
Using the Go Standard Library |
|
|
61 | (2) |
|
Understanding the Basic Data Types |
|
|
63 | (1) |
|
Understanding Literal Values |
|
|
64 | (1) |
|
|
65 | (1) |
|
Understanding Untyped Constants |
|
|
66 | (2) |
|
Defining Multiple Constants with a Single Statement |
|
|
68 | (1) |
|
Revisiting Literal Values |
|
|
69 | (1) |
|
|
70 | (1) |
|
Omitting the Variable's Data Type |
|
|
71 | (1) |
|
Omitting the Variable's Value Assignment |
|
|
72 | (2) |
|
Defining Multiple Variables with a Single Statement |
|
|
74 | (1) |
|
Using the Short Variable Declaration Syntax |
|
|
74 | (3) |
|
Using the Blank Identifier |
|
|
77 | (1) |
|
|
78 | (2) |
|
|
80 | (1) |
|
|
81 | (2) |
|
Understanding Pointer Zero Values |
|
|
83 | (1) |
|
|
84 | (1) |
|
Understanding Why Pointers Are Useful |
|
|
85 | (2) |
|
|
87 | (2) |
|
Chapter 5 Operations and Conversions |
|
|
89 | (28) |
|
Preparing for This Chapter |
|
|
90 | (1) |
|
Understanding the Go Operators |
|
|
91 | (1) |
|
Understanding the Arithmetic Operators |
|
|
91 | (4) |
|
|
95 | (1) |
|
Understanding the Comparison Operators |
|
|
95 | (4) |
|
Understanding the Logical Operators |
|
|
99 | (1) |
|
Converting, Parsing, and Formatting Values |
|
|
100 | (1) |
|
Performing Explicit Type Conversions |
|
|
100 | (2) |
|
Converting Floating-Point Values to Integers |
|
|
102 | (1) |
|
|
103 | (9) |
|
Formatting Values as Strings |
|
|
112 | (3) |
|
|
115 | (2) |
|
|
117 | (30) |
|
Preparing for This Chapter |
|
|
118 | (1) |
|
Understanding Flow Control |
|
|
119 | (1) |
|
|
119 | (2) |
|
|
121 | (3) |
|
Understanding if Statement Scope |
|
|
124 | (1) |
|
Using an Initialization Statement with an if Statement |
|
|
125 | (2) |
|
|
127 | (1) |
|
Incorporating the Condition into the Loop |
|
|
128 | (1) |
|
Using Initialization and Completion Statements |
|
|
129 | (2) |
|
|
131 | (1) |
|
|
132 | (3) |
|
|
135 | (2) |
|
|
137 | (2) |
|
Forcing Falling Through to the Next case Statement |
|
|
139 | (1) |
|
Providing a default Clause |
|
|
139 | (1) |
|
Using an Initialization Statement |
|
|
140 | (2) |
|
Omitting a Comparison Value |
|
|
142 | (1) |
|
|
143 | (2) |
|
|
145 | (2) |
|
Chapter 7 Using Arrays, Slices, and Maps |
|
|
147 | (48) |
|
Preparing for This Chapter |
|
|
148 | (1) |
|
|
149 | (1) |
|
Using the Array Literal Syntax |
|
|
150 | (1) |
|
Understanding Array Types |
|
|
151 | (1) |
|
Understanding Array Values |
|
|
152 | (2) |
|
|
154 | (1) |
|
|
154 | (2) |
|
|
156 | (2) |
|
Appending Elements to a Slice |
|
|
158 | (5) |
|
Appending One Slice to Another |
|
|
163 | (1) |
|
Creating Slices from Existing Arrays |
|
|
163 | (6) |
|
Specifying Capacity When Creating a Slice from an Array |
|
|
169 | (1) |
|
Creating Slices from Other Slices |
|
|
170 | (1) |
|
|
171 | (4) |
|
|
175 | (1) |
|
|
176 | (1) |
|
|
176 | (1) |
|
|
177 | (1) |
|
Getting the Array Underlying a Slice |
|
|
178 | (1) |
|
|
179 | (1) |
|
Using the Map Literal Syntax |
|
|
180 | (1) |
|
Checking for Items in a Map |
|
|
181 | (2) |
|
Removing Items from a Map |
|
|
183 | (1) |
|
Enumerating the Contents of a Map |
|
|
184 | (1) |
|
Understanding the Dual Nature of Strings |
|
|
185 | (4) |
|
Converting a String to Runes |
|
|
189 | (2) |
|
|
191 | (2) |
|
|
193 | (2) |
|
Chapter 8 Defining and Using Functions |
|
|
195 | (24) |
|
Preparing for This Chapter |
|
|
196 | (1) |
|
Defining a Simple Function |
|
|
197 | (2) |
|
Defining and Using Function Parameters |
|
|
199 | (1) |
|
|
200 | (1) |
|
|
201 | (1) |
|
Defining Variadic Parameters |
|
|
202 | (4) |
|
Using Pointers as Function Parameters |
|
|
206 | (1) |
|
Defining and Using Function Results |
|
|
207 | (2) |
|
Returning Multiple Function Results |
|
|
209 | (7) |
|
|
216 | (1) |
|
|
217 | (2) |
|
Chapter 9 Using Function Types |
|
|
219 | (24) |
|
Preparing for This Chapter |
|
|
220 | (1) |
|
Understanding Function Types |
|
|
220 | (2) |
|
Understanding Function Comparisons and the Zero Type |
|
|
222 | (1) |
|
Using Functions as Arguments |
|
|
223 | (2) |
|
Using Functions as Results |
|
|
225 | (1) |
|
Creating Function Type Aliases |
|
|
226 | (2) |
|
Using the Literal Function Syntax |
|
|
228 | (2) |
|
Understanding Function Variable Scope |
|
|
230 | (1) |
|
Using Functions Values Directly |
|
|
231 | (2) |
|
Understanding Function Closure |
|
|
233 | (9) |
|
|
242 | (1) |
|
Chapter 10 Defining Structs |
|
|
243 | (30) |
|
Preparing for This Chapter |
|
|
244 | (1) |
|
Defining and Using a Struct |
|
|
245 | (1) |
|
|
246 | (1) |
|
|
247 | (1) |
|
Partially Assigning Struct Values |
|
|
248 | (2) |
|
Using Field Positions to Create Struct Values |
|
|
250 | (1) |
|
|
251 | (2) |
|
|
253 | (2) |
|
Defining Anonymous Struct Types |
|
|
255 | (2) |
|
Creating Arrays, Slices, and Maps Containing Struct Values |
|
|
257 | (1) |
|
Understanding Structs and Pointers |
|
|
258 | (2) |
|
Understanding the Struct Pointer Convenience Syntax |
|
|
260 | (2) |
|
Understanding Pointers to Values |
|
|
262 | (2) |
|
Understanding Struct Constructor Functions |
|
|
264 | (2) |
|
Using Pointer Types for Struct Fields |
|
|
266 | (4) |
|
Understanding Zero Value for Structs and Pointers to Structs |
|
|
270 | (2) |
|
|
272 | (1) |
|
Chapter 11 Using Methods and Interfaces |
|
|
273 | (36) |
|
Preparing for This Chapter |
|
|
274 | (1) |
|
Defining and Using Methods |
|
|
275 | (3) |
|
Defining Method Parameters and Results |
|
|
278 | (1) |
|
Understanding Method Overloading |
|
|
279 | (3) |
|
Understanding Pointer and Value Receivers |
|
|
282 | (3) |
|
Defining Methods for Type Aliases |
|
|
285 | (2) |
|
Putting Types and Methods in Separate Files |
|
|
287 | (1) |
|
Defining and Using Interfaces |
|
|
288 | (1) |
|
|
288 | (2) |
|
Implementing an Interface |
|
|
290 | (1) |
|
|
291 | (3) |
|
Understanding the Effect of Pointer Method Receivers |
|
|
294 | (2) |
|
Comparing Interface Values |
|
|
296 | (2) |
|
Performing Type Assertions |
|
|
298 | (1) |
|
Testing Before Performing a Type Assertion |
|
|
299 | (2) |
|
Switching on Dynamic Types |
|
|
301 | (1) |
|
Using the Empty Interface |
|
|
302 | (2) |
|
Using the Empty Interface for Function Parameters |
|
|
304 | (3) |
|
|
307 | (2) |
|
Chapter 12 Creating and Using Packages |
|
|
309 | (22) |
|
Preparing for This Chapter |
|
|
310 | (1) |
|
Understanding the Module File |
|
|
311 | (1) |
|
Creating a Custom Package |
|
|
311 | (1) |
|
|
312 | (2) |
|
Understanding Package Access Control |
|
|
314 | (2) |
|
Adding Code Files to Packages |
|
|
316 | (2) |
|
Dealing with Package Name Conflicts |
|
|
318 | (3) |
|
|
321 | (2) |
|
Using Package Initialization Functions |
|
|
323 | (3) |
|
|
326 | (3) |
|
Managing External Packages |
|
|
329 | (1) |
|
|
330 | (1) |
|
Chapter 13 Type and Interface Composition |
|
|
331 | (20) |
|
Preparing for This Chapter |
|
|
332 | (1) |
|
Understanding Type Composition |
|
|
332 | (1) |
|
|
333 | (1) |
|
|
334 | (4) |
|
Creating a Chain of Nested Types |
|
|
338 | (1) |
|
Using Multiple Nested Types in the Same Struct |
|
|
339 | (1) |
|
Understanding When Promotion Cannot Be Performed |
|
|
340 | (3) |
|
Understanding Composition and Interfaces |
|
|
343 | (1) |
|
Using Composition to Implement Interfaces |
|
|
344 | (4) |
|
|
348 | (2) |
|
|
350 | (1) |
|
Chapter 14 Using Goroutines and Channels |
|
|
351 | (40) |
|
Preparing for This Chapter |
|
|
352 | (2) |
|
Understanding How Go Executes Code |
|
|
354 | (2) |
|
Creating Additional Goroutines |
|
|
356 | (4) |
|
Returning Results from Goroutines |
|
|
360 | (2) |
|
Sending a Result Using a Channel |
|
|
362 | (1) |
|
Receiving a Result Using a Channel |
|
|
363 | (3) |
|
|
366 | (1) |
|
|
366 | (5) |
|
Sending and Receiving an Unknown Number of Values |
|
|
371 | (5) |
|
Restricting Channel Direction |
|
|
376 | (5) |
|
|
381 | (1) |
|
Receiving Without Blocking |
|
|
382 | (2) |
|
Receiving from Multiple Channels |
|
|
384 | (2) |
|
|
386 | (2) |
|
Sending to Multiple Channels |
|
|
388 | (2) |
|
|
390 | (1) |
|
Chapter 15 Error Handling |
|
|
391 | (20) |
|
Preparing for This Chapter |
|
|
392 | (2) |
|
Dealing with Recoverable Errors |
|
|
394 | (1) |
|
|
394 | (2) |
|
Reporting Errors via Channels |
|
|
396 | (2) |
|
Using the Error Convenience Functions |
|
|
398 | (3) |
|
Dealing with Unrecoverable Errors |
|
|
401 | (1) |
|
|
402 | (2) |
|
Panicking After a Recovery |
|
|
404 | (2) |
|
Recovering from Panics in Go Routines |
|
|
406 | (3) |
|
|
409 | (2) |
|
Part II Using the Go Standard Library |
|
|
411 | (446) |
|
Chapter 16 String Processing and Regular Expressions |
|
|
413 | (34) |
|
Preparing for This Chapter |
|
|
414 | (1) |
|
|
415 | (1) |
|
|
415 | (2) |
|
|
417 | (2) |
|
Working with Character Case |
|
|
419 | (1) |
|
|
420 | (2) |
|
|
422 | (5) |
|
|
427 | (3) |
|
|
430 | (3) |
|
Building and Generating Strings |
|
|
433 | (2) |
|
Using Regular Expressions |
|
|
435 | (1) |
|
Compiling and Reusing Patterns |
|
|
436 | (3) |
|
Splitting Strings Using a Regular Expression |
|
|
439 | (1) |
|
|
440 | (3) |
|
Replacing Substrings Using a Regular Expression |
|
|
443 | (2) |
|
|
445 | (2) |
|
Chapter 17 Formatting and Scanning Strings |
|
|
447 | (20) |
|
Preparing for This Chapter |
|
|
448 | (1) |
|
|
449 | (1) |
|
|
450 | (2) |
|
Understanding the Formatting Verbs |
|
|
452 | (1) |
|
Using the General-Purpose Formatting Verbs |
|
|
452 | (3) |
|
Using the Integer Formatting Verbs |
|
|
455 | (1) |
|
Using the Floating-Point Formatting Verbs |
|
|
456 | (3) |
|
Using the String and Character Formatting Verbs |
|
|
459 | (1) |
|
Using the Boolean Formatting Verb |
|
|
460 | (1) |
|
Using the Pointer Formatting Verb |
|
|
460 | (1) |
|
|
461 | (3) |
|
Dealing with Newline Characters |
|
|
464 | (1) |
|
Using a Different String Source |
|
|
465 | (1) |
|
Using a Scanning Template |
|
|
466 | (1) |
|
|
466 | (1) |
|
Chapter 18 Math Functions and Data Sorting |
|
|
467 | (20) |
|
Preparing for This Chapter |
|
|
468 | (1) |
|
|
469 | (2) |
|
Generating Random Numbers |
|
|
471 | (4) |
|
|
475 | (1) |
|
Sorting Number and String Slices |
|
|
475 | (2) |
|
|
477 | (2) |
|
Sorting Custom Data Types |
|
|
479 | (6) |
|
|
485 | (2) |
|
Chapter 19 Dates, Times, and Durations |
|
|
487 | (28) |
|
Preparing for This Chapter |
|
|
488 | (1) |
|
Working with Dates and Times |
|
|
489 | (1) |
|
Representing Dates and Times |
|
|
489 | (12) |
|
|
501 | (4) |
|
Using the Time Features for Goroutines and Channels |
|
|
505 | (1) |
|
Putting a Goroutine to Sleep |
|
|
505 | (1) |
|
Deferring Execution of a Function |
|
|
506 | (1) |
|
Receiving rimed Notifications |
|
|
507 | (5) |
|
Receiving Recurring Notifications |
|
|
512 | (2) |
|
|
514 | (1) |
|
Chapter 20 Reading and Writing Data |
|
|
515 | (28) |
|
Preparing for This Chapter |
|
|
516 | (2) |
|
Understanding Readers and Writers |
|
|
518 | (1) |
|
|
518 | (1) |
|
|
519 | (2) |
|
Using the Utility Functions for Readers and Writers |
|
|
521 | (1) |
|
Using the Specialized Readers and Writers |
|
|
522 | (1) |
|
|
522 | (4) |
|
Concatenating Multiple Readers |
|
|
526 | (1) |
|
Combining Multiple Writers |
|
|
527 | (1) |
|
Echoing Reads to a Writer |
|
|
528 | (1) |
|
|
529 | (1) |
|
|
529 | (4) |
|
Using the Additional Buffered Reader Methods |
|
|
533 | (1) |
|
Performing Buffered Writes |
|
|
534 | (3) |
|
Formatting and Scanning with Readers and Writers |
|
|
537 | (1) |
|
Scanning Values from a Reader |
|
|
537 | (2) |
|
Writing Formatted Strings to a Writer |
|
|
539 | (1) |
|
Using a Replacer with a Writer |
|
|
540 | (1) |
|
|
541 | (2) |
|
Chapter 21 Working with JSON Data |
|
|
543 | (26) |
|
Preparing for This Chapter |
|
|
544 | (1) |
|
Reading and Writing JSON Data |
|
|
544 | (1) |
|
|
545 | (10) |
|
|
555 | (13) |
|
|
568 | (1) |
|
Chapter 22 Working with Files |
|
|
569 | (26) |
|
Preparing for This Chapter |
|
|
570 | (1) |
|
|
571 | (1) |
|
Using the Read Convenience Function |
|
|
572 | (2) |
|
Using the File Struct to Read a File |
|
|
574 | (4) |
|
|
578 | (1) |
|
Using the Write Convenience Function |
|
|
578 | (1) |
|
Using the File Struct to Write to a File |
|
|
579 | (2) |
|
Writing JSON Data to a File |
|
|
581 | (1) |
|
Using the Convenience Functions to Create New Files |
|
|
582 | (2) |
|
|
584 | (2) |
|
Managing Files and Directories |
|
|
586 | (2) |
|
Exploring the File System |
|
|
588 | (2) |
|
Determining Whether a File Exists |
|
|
590 | (1) |
|
Locating Files Using a Pattern |
|
|
591 | (1) |
|
Processing All Files in a Directory |
|
|
592 | (1) |
|
|
593 | (2) |
|
Chapter 23 Using HTML and Text Templates |
|
|
595 | (32) |
|
Preparing for This Chapter |
|
|
596 | (2) |
|
|
598 | (1) |
|
Loading and Executing Templates |
|
|
599 | (4) |
|
Understanding Template Actions |
|
|
603 | (20) |
|
|
623 | (2) |
|
|
625 | (2) |
|
Chapter 24 Creating HTTP Servers |
|
|
627 | (36) |
|
Preparing for This Chapter |
|
|
628 | (2) |
|
Creating a Simple HTTP Server |
|
|
630 | (1) |
|
Creating the HTTP Listener and Handler |
|
|
631 | (1) |
|
|
632 | (3) |
|
Filtering Requests and Generating Responses |
|
|
635 | (2) |
|
Using the Response Convenience Functions |
|
|
637 | (1) |
|
Using the Convenience Routing Handler |
|
|
638 | (2) |
|
Supporting HTTPS Requests |
|
|
640 | (3) |
|
Creating a Static HTTP Server |
|
|
643 | (1) |
|
Creating the Static File Route |
|
|
644 | (2) |
|
Using Templates to Generate Responses |
|
|
646 | (4) |
|
Responding with JSON Data |
|
|
650 | (1) |
|
|
651 | (1) |
|
Reading Form Data from Requests |
|
|
652 | (3) |
|
|
655 | (4) |
|
Reading and Setting Cookies |
|
|
659 | (2) |
|
|
661 | (2) |
|
Chapter 25 Creating HTTP Clients |
|
|
663 | (30) |
|
Preparing for This Chapter |
|
|
664 | (4) |
|
Sending Simple HTTP Requests |
|
|
668 | (5) |
|
|
673 | (2) |
|
Configuring HTTP Client Requests |
|
|
675 | (3) |
|
Using the Convenience Functions to Create a Request |
|
|
678 | (1) |
|
|
679 | (5) |
|
|
684 | (3) |
|
|
687 | (4) |
|
|
691 | (2) |
|
Chapter 26 Working with Databases |
|
|
693 | (30) |
|
Preparing for This Chapter |
|
|
694 | (1) |
|
|
695 | (2) |
|
Installing a Database Driver |
|
|
697 | (1) |
|
|
697 | (2) |
|
Executing Statements and Queries |
|
|
699 | (1) |
|
Querying for Multiple Rows |
|
|
700 | (6) |
|
Executing Statements with Placeholders |
|
|
706 | (2) |
|
Executing Queries for Single Rows |
|
|
708 | (1) |
|
|
709 | (2) |
|
Using Prepared Statements |
|
|
711 | (3) |
|
|
714 | (2) |
|
Using Reflection to Scan Data into a Struct |
|
|
716 | (5) |
|
|
721 | (2) |
|
Chapter 27 Using Reflection |
|
|
723 | (32) |
|
Preparing for This Chapter |
|
|
724 | (2) |
|
Understanding the Need for Reflection |
|
|
726 | (1) |
|
|
727 | (4) |
|
Using the Basic Type Features |
|
|
731 | (2) |
|
Using the Basic Value Features |
|
|
733 | (3) |
|
|
736 | (2) |
|
|
738 | (1) |
|
Obtaining Underlying Values |
|
|
739 | (2) |
|
Setting a Value Using Reflection |
|
|
741 | (3) |
|
Setting One Value Using Another |
|
|
744 | (1) |
|
|
745 | (2) |
|
Using the Comparison Convenience Function |
|
|
747 | (1) |
|
|
748 | (1) |
|
|
749 | (2) |
|
|
751 | (2) |
|
|
753 | (2) |
|
Chapter 28 Using Reflection, Part 2 |
|
|
755 | (30) |
|
Preparing for This Chapter |
|
|
755 | (1) |
|
|
756 | (1) |
|
Working with Pointer Values |
|
|
757 | (2) |
|
Working with Array and Slice Types |
|
|
759 | (1) |
|
Working with Array and Slice Values |
|
|
760 | (2) |
|
Enumerating Slices and Arrays |
|
|
762 | (2) |
|
Creating New Slices from Existing Slices |
|
|
764 | (1) |
|
Creating, Copying, and Appending Elements to Slices |
|
|
765 | (1) |
|
|
766 | (1) |
|
|
767 | (3) |
|
Setting and Removing Map Values |
|
|
770 | (1) |
|
|
771 | (1) |
|
Working with Struct Types |
|
|
772 | (3) |
|
|
775 | (2) |
|
|
777 | (1) |
|
|
778 | (1) |
|
|
779 | (1) |
|
Working with Struct Values |
|
|
780 | (2) |
|
Setting Struct Field Values |
|
|
782 | (2) |
|
|
784 | (1) |
|
Chapter 29 Using Reflection, Part 3 |
|
|
785 | (26) |
|
Preparing for This Chapter |
|
|
785 | (2) |
|
Working with Function Types |
|
|
787 | (1) |
|
Working with Function Values |
|
|
788 | (3) |
|
Creating and Invoking New Function Types and Values |
|
|
791 | (4) |
|
|
795 | (2) |
|
|
797 | (2) |
|
|
799 | (1) |
|
Getting Underlying Values from Interfaces |
|
|
800 | (1) |
|
Examining Interface Methods |
|
|
801 | (2) |
|
Working with Channel Types |
|
|
803 | (1) |
|
Working with Channel Values |
|
|
804 | (2) |
|
Creating New Channel Types and Values |
|
|
806 | (1) |
|
Selecting from Multiple Channels |
|
|
807 | (3) |
|
|
810 | (1) |
|
Chapter 30 Coordinating Goroutines |
|
|
811 | (26) |
|
Preparing for This Chapter |
|
|
812 | (1) |
|
|
813 | (2) |
|
|
815 | (5) |
|
|
820 | (2) |
|
Using Conditions to Coordinate Goroutines |
|
|
822 | (4) |
|
Ensuring a Function Is Executed Once |
|
|
826 | (2) |
|
|
828 | (2) |
|
|
830 | (2) |
|
|
832 | (1) |
|
|
833 | (2) |
|
|
835 | (2) |
|
Chapter 31 Unit Testing, Benchmarking, and Logging |
|
|
837 | (20) |
|
Preparing for This Chapter |
|
|
837 | (2) |
|
|
839 | (1) |
|
|
840 | (3) |
|
|
843 | (3) |
|
|
846 | (3) |
|
Removing Setup from the Benchmark |
|
|
849 | (1) |
|
Performing Sub-benchmarks |
|
|
850 | (1) |
|
|
851 | (3) |
|
|
854 | (1) |
|
|
855 | (2) |
|
|
857 | (214) |
|
Chapter 32 Creating a Web Platform |
|
|
859 | (24) |
|
|
859 | (1) |
|
Creating Some Basic Platform Features |
|
|
860 | (1) |
|
Creating the Logging System |
|
|
860 | (4) |
|
Creating the Configuration System |
|
|
864 | (6) |
|
Managing Services with Dependency Injection |
|
|
870 | (1) |
|
Defining Service Lifecycles |
|
|
870 | (2) |
|
Defining the Internal Service Functions |
|
|
872 | (3) |
|
Defining the Service Registration Functions |
|
|
875 | (1) |
|
Defining the Service Resolution Functions |
|
|
875 | (1) |
|
Registering and Using Services |
|
|
876 | (6) |
|
|
882 | (1) |
|
Chapter 33 Middleware, Templates, and Handlers |
|
|
883 | (36) |
|
Creating the Request Pipeline |
|
|
883 | (1) |
|
Defining the Middleware Component Interface |
|
|
884 | (1) |
|
Creating the Request Pipeline |
|
|
884 | (1) |
|
Creating Basic Components |
|
|
885 | (6) |
|
|
891 | (1) |
|
Configuring the Application |
|
|
892 | (3) |
|
Streamlining Service Resolution |
|
|
895 | (4) |
|
|
899 | (1) |
|
Creating the Layout and Template |
|
|
899 | (1) |
|
Implementing Template Execution |
|
|
900 | (4) |
|
Creating and Using the Template Service |
|
|
904 | (2) |
|
Introducing Request Handlers |
|
|
906 | (2) |
|
|
908 | (2) |
|
Preparing Parameter Values for a Handler Method |
|
|
910 | (4) |
|
Matching Requests to Routes |
|
|
914 | (4) |
|
|
918 | (1) |
|
Chapter 34 Actions, Sessions, and Authorization |
|
|
919 | (46) |
|
Introducing Action Results |
|
|
919 | (2) |
|
Defining Common Action Results |
|
|
921 | (2) |
|
Updating the Placeholders to Use Action Results |
|
|
923 | (2) |
|
Invoking Request Handlers from Within Templates |
|
|
925 | (3) |
|
Updating Request Handling |
|
|
928 | (2) |
|
Configuring the Application |
|
|
930 | (2) |
|
Generating URLs from Routes |
|
|
932 | (2) |
|
Creating the URL Generator Service |
|
|
934 | (2) |
|
|
936 | (2) |
|
|
938 | (4) |
|
Performing Data Validation |
|
|
942 | (3) |
|
|
945 | (1) |
|
Delaying Writing Response Data |
|
|
946 | (1) |
|
Creating the Session Interface, Service, and Middleware |
|
|
947 | (3) |
|
Creating a Handler That Uses Sessions |
|
|
950 | (1) |
|
Configuring the Application |
|
|
950 | (2) |
|
Adding User Authorization |
|
|
952 | (1) |
|
Defining the Basic Authorization Types |
|
|
952 | (3) |
|
Implementing the Platform Interfaces |
|
|
955 | (2) |
|
Implementing Access Controls |
|
|
957 | (2) |
|
Implementing the Application Placeholder Features |
|
|
959 | (1) |
|
Creating the Authentication Handler |
|
|
960 | (1) |
|
Configuring the Application |
|
|
961 | (3) |
|
|
964 | (1) |
|
Chapter 35 SportsStore: A Real Application |
|
|
965 | (24) |
|
Creating the SportsStore Project |
|
|
965 | (1) |
|
Configuring the Application |
|
|
966 | (1) |
|
|
967 | (1) |
|
Defining the Repository Interface |
|
|
968 | (1) |
|
Implementing the (Temporary) Repository |
|
|
969 | (1) |
|
Displaying a List of Products |
|
|
970 | (1) |
|
Creating the Template and Layout |
|
|
971 | (1) |
|
Configuring the Application |
|
|
972 | (2) |
|
|
974 | (4) |
|
Styling the Template Content |
|
|
978 | (1) |
|
Installing the Bootstrap CSS File |
|
|
978 | (1) |
|
|
979 | (1) |
|
Styling the Template Content |
|
|
979 | (2) |
|
Adding Support for Category Filtering |
|
|
981 | (2) |
|
Updating the Request Handler |
|
|
983 | (1) |
|
Creating the Category Handler |
|
|
984 | (2) |
|
Displaying Category Navigation in the Product List Template |
|
|
986 | (1) |
|
Registering the Handler and Updating the Aliases |
|
|
987 | (1) |
|
|
988 | (1) |
|
Chapter 36 SportsStore: Cart and Database |
|
|
989 | (26) |
|
Building the Shopping Cart |
|
|
989 | (1) |
|
Defining the Cart Model and Repository |
|
|
989 | (3) |
|
Creating the Cart Request Handler |
|
|
992 | (3) |
|
Adding Products to the Cart |
|
|
995 | (2) |
|
Configuring the Application |
|
|
997 | (2) |
|
Adding the Cart Summary Widget |
|
|
999 | (3) |
|
Using a Database Repository |
|
|
1002 | (1) |
|
Creating the Repository Types |
|
|
1002 | (1) |
|
Opening the Database and Loading the SQL Commands |
|
|
1003 | (2) |
|
Defining the Seed and Initialization Statements |
|
|
1005 | (1) |
|
Defining the Basic Queries |
|
|
1006 | (2) |
|
Defining the Paged Queries |
|
|
1008 | (3) |
|
Defining the SQL Repository Service |
|
|
1011 | (1) |
|
Configuring the Application to Use the SQL Repository |
|
|
1012 | (1) |
|
|
1013 | (2) |
|
Chapter 37 SportsStore: Checkout and Administration |
|
|
1015 | (34) |
|
Creating the Checkout Process |
|
|
1015 | (1) |
|
|
1015 | (1) |
|
|
1016 | (2) |
|
Disabling the Temporary Repository |
|
|
1018 | (1) |
|
Defining the Repository Methods and Commands |
|
|
1018 | (6) |
|
Creating the Request Handler and Templates |
|
|
1024 | (5) |
|
Creating Administration Features |
|
|
1029 | (5) |
|
Creating the Product Administration Feature |
|
|
1034 | (9) |
|
Creating the Categories Administration Feature |
|
|
1043 | (5) |
|
|
1048 | (1) |
|
Chapter 38 SportsStore: Finishing and Deployment |
|
|
1049 | (22) |
|
Completing the Administration Features |
|
|
1049 | (1) |
|
|
1049 | (3) |
|
Implementing the Request Handlers |
|
|
1052 | (1) |
|
|
1053 | (2) |
|
Restricting Access to the Administration Features |
|
|
1055 | (1) |
|
Creating the User Store and Request Handler |
|
|
1055 | (4) |
|
Configuring the Application |
|
|
1059 | (3) |
|
|
1062 | (3) |
|
|
1065 | (1) |
|
Installing the Certificates |
|
|
1065 | (1) |
|
Configuring the Application |
|
|
1066 | (1) |
|
|
1067 | (1) |
|
Installing Docker Desktop |
|
|
1067 | (1) |
|
Creating the Docker Configuration Files |
|
|
1068 | (1) |
|
|
1069 | (2) |
Index |
|
1071 | |