Muutke küpsiste eelistusi

E-raamat: Go Fundamentals: Gopher Guides

  • Formaat: 576 pages
  • Ilmumisaeg: 16-Nov-2022
  • Kirjastus: Addison Wesley
  • Keel: eng
  • ISBN-13: 9780137918331
  • Formaat - EPUB+DRM
  • Hind: 30,41 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Formaat: 576 pages
  • Ilmumisaeg: 16-Nov-2022
  • Kirjastus: Addison Wesley
  • Keel: eng
  • ISBN-13: 9780137918331

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

Start Writing Production-Ready Go Code Fast

Thousands of developers and teams want to start taking advantage of Go, the powerful language used in projects ranging from Kubernetes to Docker and Vault. Go Fundamentals is specifically designed to get you up-to-speed fast, to leverage your existing knowledge of other languages, and to help you avoid common mistakes made by Go newcomers.

Based on author Mark Bates's and Cory LaNou's pioneering Gopher Guides training curricula, this guide will allow you to quickly understand and use Go syntax, core features, and idioms. Reflecting Go through version 1.18--which includes Go's exciting new support for generics--this guide prepares you to write robust, reliable, well-performing production code right from the outset.





Learn how Go manages packages, modules, and dependencies Apply Go basics, such as variable declaration, types, and control flow Work effectively with collection types, iteration, functions, structs, and pointers Understand Go Slices and use them properly Write idiomatic Go, using principles such as embedding and composition Expertly use concurrency to improve code performance Create proper tests to quickly identify and fix problems Write simpler, better code with generics and interfaces Take advantage of channels, context, sync primatives, and other advanced features

Go is lightweight, simple, and perfect for modern cloud-native and microservices development, which is why Go developers are in such high demand. With this guide and six months' experience with any modern programming language, you'll have what you need to leap into Go programming.

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.
Foreword xxi
Preface xxiii
Acknowledgments xxxi
About the Authors xxxv
1 Modules, Packages, and Dependencies
1(26)
Modules
1(3)
Toolchain
2(1)
Initializing a Module
3(1)
VCS and Modules
3(1)
Packages
4(2)
Naming Packages
5(1)
Folders, Files, and Organization
6(7)
Multiple Packages in a Folder
7(2)
File Names
9(1)
Package Organization
9(4)
Importing Packages and Modules
13(3)
Import Path
13(1)
Using Imports
14(1)
Resolving Import Name Clashes
14(2)
Dependencies
16(9)
Using a Dependency
17(1)
Requiring with Go Get
18(2)
The Go Sum File
20(1)
Updating Dependencies
21(1)
Semantic Versioning
22(1)
Multiple Versions
23(1)
Cyclical Imports
24(1)
Summary
25(2)
2 Go Language Basics
27(50)
Go Language Overview
27(4)
Static Typing
27(1)
Garbage Collection
28(1)
Compilation
28(2)
Keywords, Operators, and Delimiters
30(1)
Numbers
31(4)
Picking the Correct Numeric Type
32(1)
Overflow versus Wraparound
32(2)
Saturation
34(1)
Strings
35(2)
Interpreted String Literals
35(1)
Raw String Literals
36(1)
UTF-8
37(3)
Runes
38(1)
Iterating over UTF-8 Characters
38(2)
Variables
40(8)
Variable Declaration
40(1)
Variable Assignment
41(1)
Zero Values
42(1)
Nil
42(1)
Zero Values Cheat Sheet
43(1)
Variable Declaration and Initialization
44(1)
Assigning Multiple Values
45(1)
Unused Variables
46(2)
Constants
48(3)
Typed Constants
49(1)
Untyped Constants (Inferred Typing)
50(1)
Type Inference
50(1)
Naming Identifiers
51(6)
Naming Style
53(1)
Conflicting with Package Names
53(4)
Exporting through Capitalization
57(1)
Printing and Formatting
57(18)
Formatting Functions
57(3)
New Lines
60(1)
Multiple Arguments with Println
61(1)
Using Formatting Functions
61(1)
Escape Sequences
61(2)
Formatting Strings
63(1)
Formatting Integers
63(3)
Formatting Floats
66(1)
Printing a Value's Type
67(1)
Printing a Value
67(1)
Printing a Value with More Detail
68(1)
Printing a Value's Go-Syntax Representation
69(1)
Using Formatting Verbs Incorrectly
70(1)
Explicit Argument Indexes
71(1)
Converting Strings to and from Numbers
72(3)
Summary
75(2)
3 Arrays, Slices, and Iteration
77(34)
List Types: Arrays and Slices
77(13)
Differences between Arrays and Slices
77(2)
Spotting the Difference
79(1)
Initializing Arrays and Slices
79(2)
Array and Slice Zero Values
81(1)
Indexing Arrays and Slices
81(1)
Array and Slice Types
82(1)
Array and Slice Type Definitions
83(2)
Setting Array and Slice Values
85(1)
Appending to Slices
85(2)
Appending Slices to Slices
87(3)
How Slices Work
90(14)
Length and Capacity
91(1)
Growing a Slice
92(3)
Making a Slice
95(1)
Make with Length and Capacity
96(1)
Make and Append
97(1)
What Happens When a Slice Grows
97(2)
Slice subsets
99(1)
Mutating Slice Subsets
100(1)
Copying Slices
101(1)
Converting an Array to a Slice
102(2)
Iteration
104(6)
The for Loop
104(1)
Iterating over Arrays and Slices
105(1)
The range Keyword
105(2)
Controlling Loops
107(1)
Do While Loop
108(2)
Summary
110(1)
4 Maps and Control Structures
111(30)
Maps
111(18)
Length and Capacity
112(1)
Initializing Maps
113(1)
Uninitialized Maps
114(1)
Map Keys
114(1)
Structs as Keys
115(1)
Iterating Maps
116(2)
Deleting Keys from a Map
118(2)
Nonexistent Map Keys
120(1)
Checking Map Key Existence
120(1)
Exploiting Zero Value
121(1)
Testing Presence Only
122(1)
Maps and Complex Values
123(1)
Copy on Insert
124(2)
Listing Keys in a Map
126(3)
If Statements
129(6)
The ei se Statement
130(1)
The el se if Statement
131(1)
Assignment Scope
132(2)
Logic and Math Operators
134(1)
Switch Statements
135(5)
Default
138(1)
Fallthrough
139(1)
Summary
140(1)
5 Functions
141(26)
Function Definitions
141(10)
Arguments
141(1)
Arguments of the Same Type
142(1)
Return Arguments
143(1)
Multiple Return Arguments
144(1)
Named Returns
145(2)
First-Class Functions
147(1)
Functions as Arguments
148(1)
Closures
149(1)
Anonymous Functions
150(1)
Functions Accepting Arguments from Functions
151(1)
Variadic Arguments
151(5)
Variadic Argument Position
152(1)
Expanding Slices
153(1)
When to Use a Variadic Argument
154(2)
Deferring Function Calls
156(6)
Deferring with Multiple Returns
156(1)
Defer Call Order
157(1)
Deferred Calls and Panic
158(1)
Defers and Exit/Fatal
158(1)
Defer and Anonymous Functions
159(1)
Defer and Scope
160(2)
Init
162(4)
Multiple Init Statements
163(1)
Init Order
164(1)
Using init Functions for Side Effects
164(2)
Summary
166(1)
6 Structs, Methods, and Pointers
167(28)
Structs
167(9)
Declaring New Types in Go
167(1)
Defining a Struct
168(1)
Initializing a Struct
169(1)
Initialization without Field Names
170(2)
Accessing Struct Fields
172(1)
Struct Tags
173(1)
Struct Tags for Encoding
173(2)
Using Struct Tags
175(1)
Methods
176(6)
Differences Between Methods and Functions
177(1)
Methods Expressions
177(1)
Methods on Third-Party Types
178(2)
Functions as Types
180(1)
Methods on Functions
181(1)
No Inheritance
181(1)
Pointers
182(9)
Pass by Value
183(1)
Receiving a Pointer
184(1)
Getting a Pointer
185(1)
Passing with Pointers
186(1)
Using Pointers
186(2)
Value versus Pointer Receivers
188(1)
New
189(1)
Performance
190(1)
Nil Receivers
191(2)
Nil Receivers Checks
192(1)
Summary
193(2)
7 Testing
195(36)
Testing Basics
195(7)
Naming
195(1)
The testing.T Type
196(2)
Marking Test Failures
198(1)
Using t. Error
198(2)
Usingt.Fatal (Recommended)
200(1)
Crafting Good Test Failure Messages
201(1)
Code Coverage
202(4)
Basic Code Coverage
202(1)
Generating a Coverage Profile
203(1)
The go tool cover Command
204(1)
Generating an HTML Coverage Report
205(1)
Editor Support
206(1)
Table Driven Testing
206(7)
Anatomy of a Table Driven Test
207(1)
Writing a Table Driven Test
208(3)
Subtests
211(1)
Anatomy of a Subtest
211(1)
Writing Subtests
212(1)
Running Tests
213(9)
Running Package Tests
213(1)
Running Tests with Subpackages
213(1)
Verbose Test Output
214(1)
Logging in Tests
215(1)
Short Tests
216(1)
Running Package Tests in Parallel
217(1)
Running Tests in Parallel
217(1)
Running Specific Tests
218(1)
Timing Out Tests
219(1)
Failing Fast
220(1)
Disabling Test Caching
221(1)
Test Helpers
222(7)
Defining Test Helpers
222(4)
Marking a Function as a Helper
226(1)
Cleaning Up a Helper
227(2)
Summary
229(2)
8 Interfaces
231(28)
Concrete Types versus Interfaces
231(2)
Explicit Interface Implementation
233(1)
Implicit Interface Implementation
234(1)
Before Interfaces
235(2)
Using Interfaces
237(2)
Implementing io.Writer
239(2)
Multiple Interfaces
241(1)
Asserting Interface Implementation
241(1)
The Empty Interface
242(1)
The any Keyword
242(1)
The Problem with Empty Interfaces
243(1)
Using an Empty Interface
243(1)
Defining Interfaces
243(6)
Defining a Model Interface
244(3)
Implementing the Interface
247(2)
Embedding Interfaces
249(1)
Defining an Validatable Interface
250(1)
Type Assertion
250(2)
Asserting Assertion
251(1)
Asserting Concrete Types
252(1)
Assertions through Switch
252(3)
Capturing Switch Type
253(1)
Beware of Case Order
254(1)
Using Assertions
255(2)
Defining the Callback Interfaces
255(1)
Breaking It Down
256(1)
Summary
257(2)
9 Errors
259(52)
Errors as Values
259(5)
The error Interface
261(1)
Handling Errors
262(1)
Using Errors
263(1)
Panic
264(9)
Raising a Panic
265(1)
Recovering from a Panic
265(4)
Capturing and Returning Panic Values
269(4)
Don't Panic
273(16)
Checking for Nil
274(1)
Maps
275(3)
Pointers
278(2)
Interfaces
280(3)
Functions
283(1)
Type Assertions
284(3)
Array/Slice Indexes
287(2)
Custom Errors
289(5)
Standard Errors
289(2)
Defining Custom Errors
291(3)
Wrapping and Unwrapping Errors
294(7)
Wrapping Errors
296(1)
Unwrapping Errors
297(1)
Unwrapping Custom Errors
298(3)
To Wrap or Not To Wrap
301(1)
Errors As/Is
301(6)
As
302(2)
Is
304(3)
Stack Traces
307(2)
Summary
309(2)
10 Generics
311(24)
What Are Generics?
311(23)
The Problem with Interfaces
311(4)
Type Constraints
315(2)
Multiple Generic Types
317(3)
Instantiating Generic Functions
320(1)
Defining Constraints
321(1)
Multiple Type Constraints
322(2)
Underlying Type Constraints
324(2)
The Constraints Package
326(3)
Type Assertions
329(2)
Mixing Method and Type Constraints
331(1)
Generic Types
332(2)
Summary
334(1)
11 Channels
335(38)
Concurrency and Parallelism
335(3)
Concurrency Is Not Parallelism
336(1)
Understanding Concurrency
336(2)
Go's Concurrency Model
338(4)
Goroutines
338(1)
Goroutine Memory
339(1)
The Go Scheduler
339(1)
Work Sharing and Stealing
339(2)
Don't Worry about the Scheduler
341(1)
Goroutine Example
342(1)
Communicating with Channels
342(9)
What Are Channels?
343(1)
Understanding Channel Blocking/Unblocking
343(1)
Creating Channels
343(1)
Sending and Receiving Values
344(1)
A Simple Channel Example
345(3)
Ranging over a Channel
348(1)
Listening to Channels with select
348(1)
Using select Statements
349(1)
Channels Are Not Message Queues
349(2)
Unidirectional Channels
351(1)
Understanding Unidirectional Channels
352(1)
Closing Channels
352(6)
Detecting Closed Channels on Read
354(1)
Zero Value on Closed Read
355(2)
Closing an Already-Closed Channel
357(1)
Writing to a Closed Channel
358(1)
Buffered Channels
358(5)
Basic Buffered Channel Example
359(3)
Reading from Closed Buffered Channels
362(1)
Capturing System Signals with Channels
363(8)
The os/signals Package
363(2)
Implementing Graceful Shutdown
365(2)
Listening for System Signals
367(1)
Listening for Shutdown Confirmation
368(2)
Timing Out a Nonresponsive Shutdown
370(1)
Summary
371(2)
12 Context
373(46)
The Context Interface
374(6)
Context#Deadline
374(1)
Context#Done
375(1)
Context#Err
376(1)
Contextual ue
376(2)
Helper Functions
378(1)
The Background Context
378(1)
Default Implementations
379(1)
Context Rules
380(1)
Context Nodal Hierarchy
381(3)
Understanding the Nodal Hierarchy
381(1)
Wrapping with Context Values
382(1)
Following the Context Nodes
382(2)
Context Values
384(4)
Understanding Context Values
384(2)
Key Resolution
386(2)
Problems with String Keys
388(5)
Key Collisions
388(2)
Custom String Key Types
390(3)
Securing Context Keys and Values
393(3)
Securing by Not Exporting
394(2)
Cancellation Propagation with Contexts
396(9)
Creating a Cancelable Context
397(1)
CancelingaContext
398(2)
Listening for Cancellation Confirmation
400(5)
Timeouts and Deadlines
405(3)
Canceling at a Specific Time
405(2)
Canceling after a Duration
407(1)
Context Errors
408(3)
Context Canceled Error
409(1)
Context Deadline Exceeded Error
410(1)
Listening for System Signals with Context
411(5)
Testing Signals
413(3)
Summary
416(3)
13 Synchronization
419(48)
Waiting for Goroutines with a WaitGroup
419(14)
The Problem
419(2)
Using a WaitGroup
421(1)
The Wait Method
421(1)
The Add Method
422(4)
The Done Method
426(6)
Wrapping Up Wait Groups
432(1)
Error Management with Error Groups
433(10)
The Problem
434(2)
The Error Group
436(3)
Listening for Error Group Cancellation
439(1)
Wrapping Up Error Groups
440(3)
Data Races
443(4)
The Race Detector
445(1)
Most, but Not All
446(1)
Wrapping Up the Race Detector
447(1)
Synchronizing Access with a Mutex
447(12)
Locker
449(2)
Using a Mutex
451(2)
RWMutex
453(2)
Improper Usage
455(4)
Wrapping Up Read/Write Mutexes
459(1)
Performing Tasks Only Once
459(7)
The Problem
460(2)
Implementing Once
462(1)
Closing Channels with Once
463(3)
Summary
466(1)
14 Working with Files
467(56)
Directory Entries and File Information
467(6)
Reading a Directory
468(3)
The Filelnfo Interface
471(1)
Stating a File
472(1)
Walking Directories
473(4)
Skipping Directories and Files
477(4)
Skipping Directories
478(3)
Creating Directories and Subdirectories
481(3)
File Path Helpers
484(5)
Getting a File's Extension
485(1)
Getting a File's Directory
485(1)
Getting a File/Directory's Name
486(1)
Using File Path Helpers
486(2)
Checking the Error
488(1)
Creating Multiple Directories
489(3)
Creating Files
492(5)
Truncation
495(2)
Fixing the Walk Tests
497(3)
Creating the Files
498(2)
Appending to Files
500(3)
Reading Files
503(2)
Beware of Windows
505(1)
The FS Package
506(4)
The FS Interface
508(1)
The File Interface
509(1)
Using the FS Interface
510(3)
File Paths
512(1)
Mocking a File System
513(4)
Using MapFS
515(2)
Embedding Files
517(5)
Using Embedded Files
518(2)
Embedded Files in a Binary
520(1)
Modifying Embedded Files
521(1)
Embedding Files as a String or Byte Slice
522(1)
Summary
522(1)
Index 523
Mark Bates is co-founder and instructor at Gopher Guides, the industry leader for Go training, consulting, and conference workshops. Since 2000, he has worked with some of the world's largest, most innovative companies, including Apple, Uber, and Visa. Mark discovered Go in 2013 and has attended GopherCon and hosted their lightning talks. He has spoken at conferences around the world and is a regular on the Go Time podcast.

Cory LaNou, Gopher Guides cofounder and instructor, is a full stack technologist who has specialized in start-ups for the last 20 years. Cory has deep ties to the Go community, having started one of the very first Go meetups in the world, Denver Gophers. Using his real world experience from working on projects such as InfluxDB, a highly scalable database written in Go, he has published numerous practical Go training courses and articles.