index

A

alloc_objects type 341

alloc_space type 341

allocations, reducing 331334

API changes 331

compiler optimizations 332

sync.Pool 332334

any type 2832

map of any 243244

APIs 6, 331

append function 65, 77

automaxprocs library 354

B

benchmarks 285294

being fooled by observer effect 291294

-benchtime flag 285294

-count flag 288

making wrong assumptions about micro-benchmarks 287289

not being careful about compiler optimizations 289291

not resetting or pausing the timer 286287

benchstat tool 288

block offset 309

block profiling 343

branching hazard 317

break statement 108110

bugs 45

build tags 263264

builder pattern 4244

byte slice 332334

byte type 322

bytes package 20, 121, 123

bytes.Compare function 93

C

cache line 302

cache placement policy 307

caches, CPU. See CPU caches

cancel function 187188, 190

categorizing testing 262266

build tags 263264

environment variables 264265

short mode 265266

CFS (Completely Fair Scheduler) 352

chan struct{} 205

channel size 211213

channels 91, 173174, 200204

nil channels 205210

Clean Code (Martin) 5

Close method 38, 158, 247, 252253, 255

close(ch) statement 207

Closer interface 158

closures 45

code documentation, missing 5153

code points 114

common shared package 48

common utility package 49

compilation 2

compiler optimizations 332

Completely Fair Scheduler (CFS) 352

complexity 5

compulsory misses 302

concurrency

channel size 211213

channels or mutexes, when to use 173174

concurrency impacts of workload type 181186

context type 186192

cancellation signals 187188

catching context cancellation 190192

context values 188190

deadline 186187

data races, creating with append 216218

errgroup 228231

goroutines

not being careful with loop variables and 198200

starting without knowing when to stop it 196198

mixing up with parallelism 163166

mutexes, using inaccurately with slices and maps 218221

nil channels 205210

notification channels 204205

parallelism enabled by 165

propagating inappropriate context 193196

race problems 174181

data races vs. race conditions 174179

Go memory model 179181

select and channels, expecting deterministic behavior using 200204

string formatting, side effects with 213216

deadlock 214216

etcd data race 213214

sync type, copying 231233

sync.Cond 223228

sync.WaitGroup 221223

thinking concurrency is always faster 166172

parallel merge sort 169172

scheduling 166169

concurrent mark-and-sweep 348

concurrent threads 166

conflict misses 311

constraints 32

consumer side interface 25

context switching 166

context type 186192

cancellation signals 187188

catching context cancellation 190192

context values 188190

deadline 186187

context.Canceled error 190

context.Context interface 195

context.Context type 186, 190

context.DeadlineExceeded error 190

context.WithTimeout function 187

control hazards 317

control structures

break statement 108110

defer, using inside loops 110112

map iterations 105108

Map insert during iteration 107108

ordering 105107

range loops

arguments evaluated in 98102

elements copied in 9598

pointer elements in 102105

copy function 51, 7677

-coverpkg flag 294

-coverprofile flag 294

CPU caches 300312

cache line 301304

cache placement policy 307312

CPU architecture 300301

predictability 305307

slice of structs vs. struct of slices 304305

CPU profiling 338340

CPU-bound workload 181, 184, 186

cpu.cfs_period_us parameter 352

cpu.cfs_quota_us parameter 352

-cpuprofile flag 339

critical stride 311

D

data alignment 321324

data hazards 317

data races, creating with append 216218

data structures 34

data types

floating-points 6164

integer overflows 5761

concepts 5859

detecting during addition 60

detecting during multiplication 6061

detecting when incrementing 5960

map

initialization 8487

memory leaks and 8789

octal literals 5657

slices

copies of 7677

empty 7476

initialization of 6871

length and capacity of 6468

memory leaks and 8084

slice append 7779

vs. nil 7174

values 9093

database/sql package 30, 145, 244

Deadline method 195

deadlock 214216

defer arguments and receivers 138142

argument evaluation 138141

pointer and value receivers 141142

defer calls 132, 158160

defer functions 111, 139, 144, 157, 187, 250, 252253

defer keyword 110

defer statements 110, 138, 140, 158, 250

errors in 158160

using inside loops 110112

diagnostics tooling 337347

execution tracer 344347

profiling 337344

block profiling 343

CPU profiling 338340

enabling pprof 338

goroutines profiling 342343

heap profiling 340342

mutex profiling 343344

Done method 190, 195

E

Effective Go 131

embedded struct fields 36

empty slices

not properly checking for 7476

vs. nil 7174

encoding package 2627

encoding/binary subpackage 26

encoding/json subpackage 26, 30, 74, 107, 238

environment variables 264265

Equal method 242

Err method 132, 190, 195

errgroup 228231

package 228229

error interface 134135, 153

error management

checking error type inaccurately 149152

checking error value inaccurately 152154

handling defer errors 158160

handling error 156157

handling error twice 154156

panicking 143145

wrapping errors 146149

error type 28, 143, 145

errors.As function 152

errors.Is 153154

escape analysis 329330

etcd data race 213214

Eventually function 277

execution tracer 344347

expected errors 152153

exponents 61

expressivity 2

F

filename as function input 136138

flaky tests 274

float32 type 61

float64 type 61, 128, 244

floating-points 6164

fmt.Stringer interface 214

for loops 9799, 108109, 190, 207, 286

for rows.Next() {} loop 249

forwarding 317

FPU (floating-point unit) 62

fully associative cache 308

functional options pattern 4046

functions and methods

defer arguments and receivers 138142

argument evaluation 138141

pointer and value receivers 141142

filename as function input 136138

named result parameters 129133

nil receiver, returning 133136

receivers, types to use 127129

G

GC (garbage collector) 66, 347

generics, confusion about when to use 3136

common uses and misuses 3436

concepts 3134

getters 1718

global variable 290

go command 268

Go memory model 179181

Go Time podcast 11

GODEBUG environment variable 348

GOGC environment variable 348

golang.org/x repository 288

GOMAXPROCS variable 184, 352

goroutines 179181

channels vs. mutexes, deciding between 173174

deadlines and 186187

deadlock and 215

errgroup 229231

execution tracer and 344347

false sharing and 312315

flaky tests and 274277

Go scheduling and 168

in parallel merge sort 170172

memory heaps and 327328

nil channels and 205207

not being careful with loop variables and 198200

notification channels and 204205

panics 215, 221, 232, 256

profiling 342343

race problems and 174178, 217219, 267

starting without knowing when to stop it 196198

synchronization and 211

worker-pooling pattern and 182186

goto statement 109

Grow method 120121

H

hazards 317

heap

profiling 340342

vs. stack 324330

Heap profile 337

HTTP body 250252

HTTP client 256258

http package 256

http.Client struct 256

http.Client.Timeout 257

http.Get function 257

http.ListenAndServe 259

http.Serve 259

http.Server.ReadHeaderTimeout 259

http.Server.ReadTimeout 259

http.TimeoutHandler timeout 259

http.TimeoutHandler wrapper function 260

http.Transport.ResponseHeaderTimeout timeout 257

http.Transport.TLSHandshakeTimeout timeout 257

HTTP server 259260

httptest package 262, 281283

I

I/O-bound workload 181

if/else statements 9, 11, 318

ILP (instruction-level parallelism) 316

InDelta function 62

init functions 12, 1517, 145

inlining 290, 334337

inlining budget 335

instantiation 32

instruction-level parallelism 315321

instrumentation 266

int types 3233, 5859, 65, 128, 334

int64 types 235, 311, 323

integer overflows 5761

concepts 5859

detecting an integer overflow during multiplication 6061

detecting integer overflow when incrementing 5960

detecting integer overflows during addition 60

-integration flag 264

interface{} 28

interfaces

concepts 1820

interface pollution 24

on producer side 2527

returning 2728

when to use 2124

common behavior 2122

decoupling 22

restricting behavior 2324

inuse_objects type 341

inuse_space type 341

io package 18, 28

io.Closer interface 249, 252253

io.EOF error 153

io.LimitedReader exported struct 28

io.Reader abstraction 1920, 137

io.Reader input 182

io.Reader interface 19, 28, 331

io.ReadFull function 131

io.StringWriter interface 120

io.WriteCloser interface 38

io.Writer abstraction 1920

io.Writer implementation 251

iotest package 262, 283285

J

JSON-handling mistakes 238244

JSON and monotonic clock 240243

map of any 243244

unexpected behavior due to type embedding 238240

json.Marshaler interface 239240

L

len function 99, 115, 121

linters 5354

load factor 86

locality of reference 301

Lock method 37, 336337

loop label 109

loops, using defer inside 110112

M

main function 1314, 325326

main package 1214

make function 86, 211

mantissas 61

maps

initialization 8487

iterations 105108

map insert during 107108

ordering 105107

memory leaks and 8789

Marshal function 30

Marshaler interface 239

MarshalJSON function 239

MarshalJSON method 240

Martin, Robert C. 5

math package 59

math.MinInt integer 60

mechanical sympathy 300

memory fence 222

memory leaks

maps and 8789

slices and 8084

leaking capacity 8081

slice and pointers 8184

memory-bound workload 181

MESI (Modified, Exclusive, Shared, or Invalid) 314

methods. See functions and methods

Mutex profile 338

mutexes 173174, 176

mutual exclusion 176

profiling 343344

using inaccurately with slices and maps 218221

N

named result parameters 129133

NaN (Not-a-Number) 62

nanoseconds 235

nested code 912

net package 47

net.Dialer.Timeout 257

Network Time Protocol (NTP) 240

nil error 132

nil receiver, returning 133136

nil vs. empty slices 7174

non-unit stride 307

Not-a-Number (NaN) 62

notification channels 204205

now dependency 280

NTP (Network Time Protocol) 240

O

octal literals 5657

off-die 301

on-die 300

optimizations

allocations, reducing 331334

API changes 331

compiler optimizations 332

sync.Pool 332334

concurrent code that leads to false sharing 312315

CPU caches 300312

cache line 301304

cache placement policy 307312

CPU architecture 300301

predictability 305307

slice of structs vs. struct of slices 304305

data alignment 321324

GC (garbage collector) 347352

concepts 347349

examples 349352

Go diagnostics tooling 337347

execution tracer 344347

profiling 337344

inlining 334337

instruction-level parallelism 315321

running Go in Docker and Kubernetes 352354

stack vs. heap 324330

organization of code and project

code documentation 5153

getters and setters 1718

init functions 1217

interfaces

interface pollution 1824

on producer side 2527

returning 2728

nested code 912

package name collisions 5051

project misorganization 4648

package organization 4748

project structure 4647

suboptimal or unidiomatic 5

suboptimal organization of code 5

utility packages 4850

variable shadowing 79

os.File 253255

P

package name collisions 5051

package organization 4748

padding 314

-parallel flag 268269

parallel merge sort 169172

parallel threads 166

parallelism 163166, 315321

perflock tool 288

periodic scavengers 348

pointers 8184, 91, 102105, 141142

pprof endpoint 338

printAlloc function 82

println built-in function 325

Producer side interface 25

productivity, lack of 6

profiling 337344

blocks 343

CPUs 338340

enabling pprof 338

goroutines 342343

heaps 340342

mutexes 343344

R

-race flag 174, 231, 266268

race problems 174181

data races vs. race conditions 174179

range expression 100

range loops 31, 9598, 100, 106, 117118

arguments evaluated in 98102

array 100102

channels 100

elements copied in

concepts 96

value copy 9698

pointer elements in 102105

range operator 99101, 103, 116117

Read method 19, 331

readability 5

receivers 126129

redis package 50

reflect package 91

reflect.DeepEqual function 91

reflection 91

regexp package 145

Reset method 237

ResetTimer method 286

return statement 135, 138, 159, 234, 255256, 325, 329

-run flag 273

runes 113115, 123

runnable state 166

runtime.GOMAXPROCS(int) function 184

runtime/trace package 346347

S

Scan error 160

scheduling 166169

select statement 109110, 200204, 207, 209210

set index 309

set-associative cache option 308

SetConnMaxIdleTime parameter 245

SetConnMaxLifetime parameter 245

SetMaxIdleConns parameter 245

SetMaxOpenConns parameter 245

setters 1718

sharing down 329

sharing up 329

-short flag 265266

-shuffle flag 268, 270

SIGPROF signal 338

simplicity of Go 3

slice capacity 68

slice length 68

slices

copies of 7677

empty slices

not properly checking for 7476

vs. nil 7174

initialization of 6871

length and capacity of 6468

memory leaks and 8084

leaking capacity 8081

slice and pointers 8184

slice append 7779

sort package 21, 34

sort.Float64s function 35

sort.Interface interface 34

sort.Ints function 35

sort.Sort(sort.Interface) function 35

SQL mistakes 244249

forgetting about connections pooling 245246

forgetting sql.Open doesn't necessarily establish connections to database 244245

mishandling null values 247248

not handling row iteration errors 248249

not using prepared statements 246247

sql.ErrNoRows sentinel error 153

sql.NullBool wrapper 248

sql.NullFloat64 248

sql.NullInt32 wrapper 248

sql.NullInt64 248

sql.NullString wrapper 248

sql.NullTime 248

sql.NullXXX types 248

sql.Rows 252253

stability 2

stack vs. heap 324330

standard library

HTTP client 256258

HTTP server 259260

JSON-handling mistakes 238244

JSON and monotonic clock 240243

map of any 243244

unexpected behavior due to type embedding 238240

providing a wrong time duration 235

return statement after replying to HTTP request 255256

SQL mistakes 244249

forgetting about connections pooling 245246

forgetting sql.Open doesn't necessarily establish connections to database 244245

mishandling null values 247248

not handling row iteration errors 248249

not using prepared statements 246247

time.After and memory leaks 235238

transient resources 249255

HTTP body 250252

os.File 253255

sql.Rows 252253

Stop() method 237

String method 33, 215216

Stringer interface 214

strings

concatenation 119121

conversions 121123

formatting, side effects with 213216

deadlock 214216

etcd data race 213214

iteration 115118

package 20, 118, 120123

runes 114115

substrings and memory leaks 123125

trim functions 118119

type 3233, 128

strings.Builder struct 120121

struct{} type 48

structural hazards 318

sumValue function 325

superscalar processors 316

switch statement 109110, 201

sync element 233

sync package 128, 176, 223, 231, 233

sync type, copying 231233

sync.Cond package 223228

sync.Mutex type 37, 336

sync.Pool 332334

sync.WaitGroup 221223

Sync() method 254

sync/atomic package 176177, 221

T

task functions 182

testify library 62

testing

categorizing 262266

build tags 263264

environment variables 264265

short mode 265266

enabling race flag 266268

exploring all Go testing features 294297

code coverage 294

setup and teardown 296297

testing from different package 295

utility functions 295296

sleeping in unit tests 274277

table-driven tests 271274

test execution modes 268270

-parallell flag 269270

-shuffle flag 270

time API 278281

utility packages 281285

httptest package 281283

iotest package 283285

writing inaccurate benchmarks 285294

being fooled by observer effect 291294

making wrong assumptions about micro-benchmarks 287289

not being careful about compiler optimizations 289291

not resetting or pausing the timer 286287

threadcreate profile 344

threads 166, 300

time API 281

time package 235

time.After and memory leaks 235238

time.After resources 236

time.Duration API 235

time.Now function 279

time.Time methods 238

time.Time type 240

time.Timer struct 17, 237

-trace flag 344

transient resources 249255

HTTP body 250252

os.File 253255

sql.Rows 252253

trim functions 118119

TrimRight function 118

TrimSpace function 123

TrimSuffix function 118

Truncate method 242

type embedding 3639

U

uint type 5859

under-optimized code 6

unexpected errors 153

unicode/utf8 package 116

unidiomatic organization of code 5

Unit stride 306

Unlock method 37

UUIDs (universally unique identifiers) 123

V

variable shadowing 79

victim caches 303

virtual cores 300

W

Wait method 170, 221, 226

WithContext function 229

work-stealing 168

worker pooling pattern 182

wrapping errors 146149

Write method 35, 38

WriteHeader method 145

WriteString method 120

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.244.45