calling
cancellation deadlines on contexts, 374
cancellation events
capacity
capitalization for exporting variables, 57
capturing
casting values, 45
chan keyword, 343
channels
choosing numeric types, 32
code coverage
comparison operators, 135
complex64 numeric type, 31
complex128 numeric type, 31
concrete types
concurrency. See also synchronization
contexts
const keyword, 48
constraints. See type constraints
constraints.Integer constraint, 327
constraints.Signed constraint, 327
context.Context.Deadline method, 374
contexts
context.WithCancel function, 397
control structures
converting
copying
custom errors
data races
data types
debug.PrintStack function, 307
debug.Stack function, 307
declaring. See also defining
decrementing integers, 122
deferring function calls, 156
defining. See also declaring
directories. See also files
disabling test caching, 221
discarding variables, 47
embed package, 517
embedding
errgroup.Group.Go method, 437
error groups
errors. See also testing
errors.New function, 261
escape characters
exporting
extensions, retrieving, 485
file systems
filepath package, 484
filepath.Base function, 486
files. See also directories
first-class functions, 147
fmt.Stringer interface, 241
folders, package folder structure, 4, 6–13. See also directories
for loops
formatting
strings
verbs for, 61
Fprint functions, 59
fs.ErrExit error, 489
fs.File interface, 509
functions. See also interfaces
anonymous, 150
accepting from other functions, 151
deferring calls, 156
definitions, 141
as first class, 147
generics, 311
methods on, 181
methods versus, 177
test function signatures, 196
test helpers, 222
garbage collection, 28
generic functions, 311
generic package names, avoiding, 6
go build command, 29
go help mod command, 2
go help test command, 477
go mod command, 2
go mod init command, 3
go vet command, 71
golang.org/x/sync/errgroup package, 434
go.mod file, 2
goroutines, 338. See also channels; contexts; synchronization
graceful shutdown
implementation-specific numeric types, 31
import aliases, 16
import keyword, 14
importing
incrementing integers, 122
indexing
initializing
int8 numeric type, 31
int16 numeric type, 31
int32 numeric type, 31
int64 numeric type, 31
integers
interfaces
interpreted string literals, 35
iteration
keys
keywords, list of, 30
length
listener function, 353
listening
to channels
listings
a.go file, 8
anonymous functions, 150
array of four strings, 78
asserting interface implementation, 242
bad folder files listing, 8
bad identifier names, 52
bad package build, 9
bar/bar.go file, 15
b.go file, 8
blocking/unblocking channels, 345
calling methods, 177
casting values, 45
closing already-closed channels, 357
code coverage, 203
constraints.Integer constraint, 327
constraints.Ordered constraint, 328
constraints.Signed constraint, 327
context.Context interface, 374
context.Context.Deadline method, 374
context.WithCancel function, 397
coverage profiles on per-function basis, 207
creating arrays versus slices, 79
custom data type usage, 168
data types in arrays and slices, 83
debug.PrintStack function, 307
debug.Stack function, 307
declaring constants, 48
declaring methods, 176
declaring new data types, 167
declaring variables, 40
deferred function calls and exit/fatal message, 159
deferred function calls and panics, 158
deferring function calls, 156
defining structs, 169
delete function, 118
demo module files listing, 15
disabling test caching, 221
discarding variables, 47
do while loops, 109
else if statements, 132
embed package, 517
embedding files as strings/byte slices, 522
errgroup.Group.Go method, 437
error types, 296
errors with formatting verbs, 70
errors.New function, 261
escape characters and , 62
expanding slices with variadic operator, 154
exporting variables, 57
external dependencies file structure, 20
failing fast when testing, 221
filepath package, 484
filepath.Base function, 486
filepath.Dir function, 485
filepath.Ext function, 485
flect.Dasherize function, 17
float formatting verbs, 66
fmt package, 58
fmt.Errorf method, 262
fmt.Fprint function, 59
fmt.Print function, 59
fmt.Println function, 60
fmt.Stringer interface, 241
foo type, 25
foo/bar/bar.go file, 15
foo.go file, 13
for loops, 105
fs package, 507
fs.File interface, 509
fs.FS interface, 508
function definitions, 141
functions accepting other function arguments, 151
generics, 316
go help test command, 477
go mod command, 2
go mod init command, 3
Go module files listing, 1
go vet command, 71
golang.org/x/exp/constraints package, 326
golang.org/x/sync/errgroup package, 434
go.mod file updates, 20
goroutine usage example, 342
goroutines, 338
go.sum file, 21
handling errors, 263
http.HandlerFunc type, 181
if statements, 130
importing modules with semantic versioning, 22
inheritance, 182
initializing arrays and slices, 80
initializing variables, 44
integer formatting verbs, 64
interpreted string literals, 35
listener function, 353
log.Fatal function, 273
logging in tests, 215
make function with append function, 97
mixing type and method constraints, 331
modifying constants, 48
multiple interfaces, 241
multiple Println arguments, 61
mutating subsets of slices, 100
names folder files listing, 13
naming files, 9
naming variables, 53
new lines, 60
order of execution for deferred function calls, 157
order of execution for init functions, 164
os.DirEntry type, 468
os.DirFS function, 512
os.FileMode type, 482
os.Interrupt type, 365
os.OpenFile function, 501
os.Signal type, 364
panic function, 265
passing by value, 184
path package, 54
pointer usage, 187
printing stack traces, 308
printing value type, 67
range keyword, 106
range loops, 348
receiving pointers, 184
recover function, 266
return arguments, 143
returning errors, 144
runes, 38
running package tests, 213
select statements, 349
sending TEST_SIGNAL signal, 416
sending/receiving values via channels, 345
signal.Notify function, 364
signal.NotifyContext function, 412
smtp package, 7
sound package, 7
strconv.ParseInt function, 73
string formatting verbs, 63
string keys in contexts, 388
struct tags, 173
structure of table driven tests, 208
subsets of slices, 99
sync package, 447
sync.Locker interface, 450
sync.Locker.Lock method, 450
sync.Locker.Unlock method, 451
sync.WaitGroup.Add method, 422
sync.WaitGroup.Wait method, 422
test file naming conventions, 196
test function signatures, 196
testing.T type, 197
testing.TB.Helper method, 226
testing.T.Run method, 211
theoretical representation of slices, 91
time.Ticker function, 351
typed constants, 49
unidirectional channels, 352
uninitialized maps, 114
unused variables, 47
Unwrapper interface, 299
validating type assertions, 252
verbose test output, 214
verifying concrete types with type assertions, 252
work stealing, 341
wraparound example, 33
writing to closed channels, 358
zero values for arrays and slices, 81
lists
locking resources
log.Fatal function, 273
logging in tests, 215
logic. See boolean logic; control structures
loops
package keyword, 5
definition of, 4
initializing. See init functions
name conflicts
panic function, 265
panics
parallelism
ParseInt function, 73
passing
positive number of goroutines, adding
Print functions, 59
printing
Println function
quotation marks for string literals, 35
scope
selecting numeric types, 32
semantic versioning, 22
sending
shared access
shutdown, graceful
signal.Notify function, 364
signal.NotifyContext function, 412
single execution of task
skipping
slices
string keys in contexts, 388
structs, 167
structural typing, 235
subsets
sync package, 447
synchronization
error groups
with mutexes
race conditions
sync package, 447
waitgroups
sync.Locker.Lock method, 450
sync.Locker.Unlock method, 451
system signals
capturing, 363
test caching, disabling, 221
test failures
test function signatures, 196
test helpers, 222
TEST_SIGNAL signal, sending, 416
testing
testing framework, 195
testing.TB.Helper method, 226
testing.T.Log method, 215
testing.T.Run method, 211
threads. See goroutines
time.Ticker function, 351
timing out
type of value, printing, 67
typed constants, 49
types. See data types; interfaces
waitgroups
work stealing, 341
wrapping
writing