TAG
Golang
69 notes
- 1.1 make vs newhistorical
What make and new are in Go, why memory allocation is needed, how they are used, their differences, and their implementation details.
- 1.2 reflectionhistorical
What reflection is, how Go implements reflection through interfaces, and the relationship between Type and Value.
- 1.3 errorhistorical
The distinction between exception and error in Go, how errors are used and handled, their implementation, and practical patterns.
- 1.4 interfacehistorical
Empty and non-empty interfaces, how interfaces are used, type conversion and assertions, iface/eface internals, nil comparison, and interface conversion.
- 1.5 functionhistorical
What functions are in Go, variadic parameters, multiple return values, named returns, closures, init functions, methods, stacks, and common functions.
- 1.6 stringhistorical
Character sets and Unicode, basic Go string usage, string/[]byte conversion, StringHeader, and string immutability.
- 1.7 maphistorical
What a map is, how hash buckets work, collision handling, expansion, and the historical Go map implementation.
- 1.8 unsafehistorical
Pointer types in Go, why pointers are needed, the unsafe pointer type, examples, and the underlying APIs.
- 1.9 panic and recoverhistorical
What panic and recover are, why they are needed, how to use them, and the runtime calls behind them.
- 1.10 Type Systemhistorical
Built-in and custom Go types, type metadata, _type, extra metadata for built-in types, and uncommontype metadata for custom types.
- 1.11 arrayhistorical
Fixed-length arrays in Go, value semantics, range iteration, compiler representation, literal initialization, and bounds checking.
- 1.12 slicehistorical
1. What is a slice A dynamically growable array 2. Why slices are needed Arrays have a fixed number of elements and cannot grow dynamically 3. How to use slices 3.1. Basic usage 3.2. Function parameters pass the slice descriptor - although changes to the backing array are visible, append may replace the backing array, so return the slice when needed 3.3. nil slice and empty slice
- 1.13 deferhistorical
What defer is, why it is used, cleanup patterns, interaction with return values and closures, LIFO ordering, recover, and its historical runtime implementation.
- 2.1 contexthistorical
Goroutine context, deadlines, cancellation signals, request-scoped data, Context/canceler implementations, WithCancel/WithTimeout/WithValue, and references.
- 2.2 sync.WaitGrouphistorical
What sync.WaitGroup is, an example of waiting for goroutines, and its counter-based Add, Done, and Wait behavior.
- 2.3 synchistorical
An overview of the synchronization primitives provided by Go's sync package and links to Mutex, RWMutex, Cond, Once, Map, Pool, WaitGroup, and atomic.
- 2.4 sync.maphistorical
What sync.Map is, concurrency-safety approaches, usage, its read/dirty data structures, and a summary of Load, Store, Delete, and dirty-to-read promotion.
- 2.5 sync.poolhistorical
What sync.Pool is, why temporary object caching can reduce allocation and GC pressure, usage, fmt integration, source structures, Get/Put, GC cleanup, and summary.
- 2.6 selecthistorical
What select is, basic usage, random selection, empty select, nil channels, for-select exit, timeouts, quit channels, internals, and references.
- 2.7 sync.Oncehistorical
What sync.Once is, singleton usage, its atomic+Mutex implementation, and a modified version that returns an error.
- 2.8 sync.Mutexhistorical
What Mutex is and examples showing the difference between unsynchronized access and access protected by sync.Mutex.
- 2.9 sync.RWMutexhistorical
What sync.RWMutex is and an example using write locks and read locks around a shared map.
- 2.10 sync.Condhistorical
What sync.Cond is, Wait/Broadcast/Signal semantics, and a blocking-queue example using condition variables.
- 2.11 atomichistorical
What atomicity is, what atomic.Value is, how to use it, and the implementation of Store and Load.
- 2.12 channelhistorical
CSP concurrency model, channel usage and closing patterns, happens-before, hchan internals, creation, receive, send, close, and references.
- 2.13 concurrenthistorical
Goroutine and channel, the sync package, synchronization, happens-before rules, concurrency patterns, and multi-core CPU references.
- 2.14 goroutinehistorical
What a goroutine is, how to create one, how go f(args) maps to runtime.newproc, goroutine pools, and GMP scheduling.
- 2.15 Goroutine Poolhistorical
What a goroutine pool is, why it is usually unnecessary, and two example designs for reusing goroutines.
- 3.1 GMPhistorical
Goroutine scheduler, GM model, GMP model, P/M/G, goroutine creation flow, preemptive scheduling, and references.
- 3.2 Escape Analysishistorical
How Go uses escape analysis to decide whether values created with new are allocated on the heap or stack, why escape analysis matters, and a compiler-output example.
- 3.3 Go Build Processhistorical
Text files, executable build process, compilation, linking, Go bootstrap flow, startup flow, and references.
- 3.4 Memory Managementhistorical
Golang memory regions and the relationship between runtime.MemStats, RSS, heap, stack, HeapSys, HeapInuse, HeapIdle, and HeapReleased.
- 3.5 Plan 9 Assemblyhistorical
1. What Plan 9 assembly is 2. Registers 3. Instruction format 4. Basic instructions 5. Advanced instructions 6. Typical function stack frame 7. Usage 8. References
- 3.6 Memory Alignmenthistorical
Machine word length, memory addressing, alignment boundaries, why alignment is needed, data-structure alignment, address alignment, and references.
- 3.7 GChistorical
Go GC triggers, phases, tri-color marking, write barriers, observation, tuning, and memory reuse.
- 3.8 Golang Stack Managementhistorical
What the stack is, Go stack characteristics, dynamic growth, contiguous vs segmented stacks, and references.
- 3.9 Golang Heap Managementhistorical
Heap, heap memory layout, allocation units, mcache/mcentral/mheap, escape analysis, allocation flow, and references.
- 4.1 unittesthistorical
1. What it is Unit testing 2. Usage - filename xxx_test.go - import testing - function name must be TestXXX - run - go test . 3. References
- 4.2 pprofhistorical
1. What pprof is Golang performance analysis tool. 2. How to use pprof runtime/pprof, net/http/pprof, benchmark 3. How pprof works 4. References
- 4.3 benchmarkhistorical
How to write and run Go benchmarks, inspect memory allocations, and generate CPU, memory, block, trace, and mutex profiles.
- 4.4 Golang Memory Leakshistorical
Memory leaks, root references, goroutine leaks, non-runtime memory, analysis workflow, examples, and references.
- 4.5 tracehistorical
1. Usage Steps: 1. Import package: import runtime/trace 2. Start analysis: trace.Start(file), stop analysis: trace.Stop() 3. Command-line analysis - go tool trace trace.out - 2. References
- consulhistorical
1. What it is A component for service registration and discovery 2. Building a local cluster 2.1. Download 2.2. Configuration files 2.2.1. Create directories 2.2.2. Configuration files server1 server2 server3 2.3. Start 2.4. Test Add service configuration Add service web UI 3. References
- etcdhistorical
1. Installation Download Releases · etcd-io/etcd Extract and configure environment variables 2. web UI Releases · evildecay/etcdkeeper 3. References etcd | Home
- hystrixhistorical
1. circuit A Go implementation of Hystrix for circuit breaking 2. Usage hystrix.go main.go 3. References
- microhistorical
1. Install Micro 1.1. Option 1 Download Releases · micro/micro Extract and configure environment variables 1.2. Option 2 Prerequisite: configure GOBIN Download source Install into GOBIN 2. References
- protobufhistorical
1. What it is An efficient serialization and deserialization format 1.1. Ordinary serialization 1.2. protobuf serialization 1.3. Comparison 2. Installation 3. Usage 4. References
- retryhistorical
1. What it is A failed remote-service call may succeed when attempted again 2. When retries are needed Network errors can be retried; logic errors do not need retries Long-lasting network failures should not be retried indefinitely Non-idempotent requests cannot be retried 3. Retry strategy 4. Go retry 5. References
- Go Environment Setuphistorical
Installing Go, configuring GOROOT/GOPATH/GOBIN/GOPROXY/GOPRIVATE, common Go commands, and IDE setup.
- Go Language Basicshistorical
Go keywords, data structures, functions, interfaces, packages, concurrency, reflection, errors, files, and source-code references.
- Learning Gohistorical
Go characteristics, comparison with Java, language basics, data structures, concurrency, memory management, build process, performance tools, and references.
- WaitGrouphistorical
What WaitGroup is, an example of waiting for goroutines, and its counter-based Add, Done, and Wait behavior.
- httphistorical
1. What it is http.Get/http.Post/http.PostForm all call client.Do underneath; Client is safe for concurrent use; NewRequest builds a Request; Client sends it and returns a Response 2. Usage 2.1. http builder 3. HTTP internals 4. References
- iohistorical
1. What it is I/O operations 2. What it contains 2.1. os 2.2. io 2.3. ioutil 2.4. bufio 3. References
- jsonhistorical
Reference: bashtian/jsonutils: Converter for JSON data to a Go struct or a Java class for GSON
- loghistorical
Using the Zap logging library in Go projects; using the third-party logrus logging library
- packagehistorical
1. What it is How Go organizes source code 2. Package initialization flow 3. Circular dependencies 4. Common packages 5. References
- sqlhistorical
1. What it is 2. What it contains 2.1. Connections 2.2. CRUD 2.3. Transactions 3. Prepared statements 4. Other libraries 4.1. sql-builder 4.2. xorm 5. References
- sync.singleflighthistorical
A singleflight DoChan usage example with context timeout and shared results.
- xormhistorical
1. reverse tool 1.1. Installation 1.2. Usage Configuration file tao.yml Command 2. References