TAG
Golang
64 notes
- 1.1 make vs newhistorical
Make and new are Go built-ins. These notes compare their memory allocation, initialization, and return values.
- 1.2 reflectionhistorical
Reflection lets programs inspect and manipulate type information at runtime. These notes examine its relationship with type information stored in interfaces.
- 1.3 errorhistorical
Go error handling distinguishes returned errors from exceptional conditions. These notes begin with that distinction and record handling approaches and examples.
- 1.4 interfacehistorical
Interfaces retain information about the type and value assigned to them. These notes begin with empty interfaces and examine their internal representation.
- 1.5 functionhistorical
Go treats functions as first-class values and supports named and anonymous functions. These notes examine their definitions and usage.
- 1.6 stringhistorical
Computers store characters as bytes, with character sets defining the mapping. These notes introduce Go string concepts through the development of encodings such as ASCII.
- 1.7 maphistorical
Go maps associate keys with values and organize data in buckets. These notes examine access, resizing, and concurrent usage through that structure.
- 1.8 unsafehistorical
Pointers hold memory addresses and allow called functions to modify caller-supplied data. These notes use pointers to introduce unsafe operations.
- 1.9 panic and recoverhistorical
Panic interrupts normal execution, while recover can handle a panic within deferred code. Examples record how both mechanisms work together.
- 1.10 Type Systemhistorical
Go's built-in and user-defined types carry type metadata. These notes examine how runtime metadata and headers describe different types.
- 1.11 arrayhistorical
Go arrays have a fixed length and are copied during assignment and argument passing. These notes examine array usage through those properties.
- 1.12 slicehistorical
Slices provide an expandable view over fixed-length arrays. These notes introduce their structure and usage through the limits of arrays.
- 1.13 deferhistorical
defer: A mechanism that lets a function be executed after the current function finishes. Here, finishing includes both normal termination through return and abnormal termination caused by panic.
- 2.1 contexthistorical
Context carries cancellation signals, timeouts, deadlines, and key-value data between goroutines to coordinate related task lifecycles.
- 2.2 sync.WaitGrouphistorical
WaitGroup lets a goroutine wait for other goroutines to finish, using a counter to track outstanding work.
- 2.3 synchistorical
The sync package provides primitives such as locks, condition variables, Once, and WaitGroup. These notes organize their roles in concurrent programs.
- 2.4 sync.maphistorical
Sync.Map provides thread-safe key-value storage for concurrent access. These notes examine its usage scenarios, internal structure, and differences from an ordinary map.
- 2.5 sync.poolhistorical
Sync.Pool temporarily holds reusable objects so later operations can reuse them, reducing allocations and garbage-collection pressure.
- 2.6 selecthistorical
Go select waits on multiple channel operations and executes a branch when an operation can proceed, in a form similar to I/O multiplexing.
- 2.7 sync.Oncehistorical
Once guarantees that an action executes only once. These notes examine its usage and implementation through scenarios such as singletons.
- 2.8 sync.Mutexhistorical
Mutex provides mutual exclusion, implements Locker, and starts unlocked at its zero value. These notes cover locking, unlocking, and implementation details.
- 2.9 sync.RWMutexhistorical
RWMutex distinguishes read and write locks, acquired with RLock and Lock. These notes record usage and implementation.
- 2.10 sync.Condhistorical
Cond is Go's condition variable, used with a lock to coordinate waiting and notification. These notes compare it with Java's Condition.
- 2.11 atomichistorical
Atomicity treats an operation or group of operations as a whole. These notes examine Go atomic operations in concurrent access.
- 2.12 channelhistorical
Concurrent programs can coordinate through shared memory or message passing. These notes introduce Go channels through those two models.
- 2.13 concurrenthistorical
Execution order within a goroutine differs from visibility across goroutines. These notes organize Go concurrency constraints through synchronization events.
- 2.14 goroutinehistorical
Goroutines are user-level execution units implemented by Go. These notes connect them with processes and threads and record their creation and use.
- 2.15 Goroutine Poolhistorical
A goroutine pool reuses existing goroutines. These notes compare creation, destruction, and reuse costs before discussing when pooling is useful.
- 3.1 GMPhistorical
GMP: The coroutine scheduling model in Golang: given M threads and N goroutines, how should goroutines be assigned to threads for execution?
- 3.2 Escape Analysishistorical
Objects created in Java or C++ are generally allocated on the heap, while objects created with new in Golang are allocated on the heap or stack according to escape analysis.
- 3.3 Go Build Processhistorical
Go source files must be built into executable programs. These notes start with text and binary representations and follow the build process.
- 3.4 Memory Managementhistorical
Go program memory is organized into regions with different purposes. These notes begin with global variables and constants and examine allocation and reclamation.
- 3.5 Plan 9 Assemblyhistorical
Go uses Plan 9-style assembly to represent low-level operations before conversion to machine instructions. These notes record syntax and examples.
- 3.6 Memory Alignmenthistorical
Memory Alignment: The CPU addresses memory through the address bus, while memory transfers data to the CPU through the data bus.
- 3.7 GChistorical
These Go garbage-collection notes cover its purpose, triggers, three-color marking, and mechanisms for reducing stop-the-world time.
- 3.8 Golang Stack Managementhistorical
The stack holds data during function calls, with space allocated through calls. These notes record Go stack organization, allocation, and management.
- 3.9 Golang Heap Managementhistorical
Go manages heap memory in its runtime rather than calling the operating system for every allocation. These notes examine heap organization and allocation through the TCMalloc approach.
- 4.1 unittesthistorical
Go unit tests live in files ending in _test.go. These notes use test code to record assertions, execution, and test organization.
- 4.2 pprofhistorical
Pprof analyzes Go program performance. These notes distinguish profiling for command-line and web applications and record analysis commands.
- 4.3 benchmarkhistorical
Examples such as bench.go and bench_test.go demonstrate how to write and run Go benchmarks.
- 4.4 Golang Memory Leakshistorical
A goroutine that does not exit as intended may remain until the program ends. These notes use this problem to examine Go memory leaks and troubleshooting.
- 4.5 tracehistorical
Runtime/trace records Go execution traces. These notes start with importing the package and collecting data, then describe viewing the results.
- consulhistorical
Consul provides service registration and discovery. These notes include server and client configuration and examples of registration from Go programs.
- etcdhistorical
These notes cover downloading and configuring etcd, followed by basic client usage through Go examples.
- hystrixhistorical
These notes record usage and implementation of a Go Hystrix library, starting with circuit breaking for failed calls and related fault handling.
- microhistorical
These notes record Micro installation and environment setup, followed by its use in Go microservice examples.
- protobufhistorical
Protobuf provides efficient data serialization and deserialization. These notes use message definitions and code examples to show its usage in Go.
- retryhistorical
A failed remote call may succeed on another attempt. These notes distinguish network from logical errors to examine when retries are appropriate.
- rpchistorical
Server and client code examples demonstrate Go RPC calls and how both sides organize interfaces and data.
- Go Environment Setuphistorical
A Go environment involves installation paths, workspace settings, and modules. These notes record configuration through Windows, Linux, and go env.
- Go Language Basicshistorical
Go's basic syntax requires attention to variable scope in concurrent code. These notes begin with loop-variable examples and record practical language issues.
- Learning Gohistorical
Go is a statically typed compiled language. These notes connect its characteristics with environment setup, basic syntax, and runtime topics.
- WaitGrouphistorical
WaitGroup lets a goroutine wait for other goroutines to finish, using a counter to track outstanding work.
- cgohistorical
Using cgo on Windows requires a toolchain such as MSYS2 and GCC. These notes record setup steps and Go-to-C usage.
- dlvhistorical
These notes record Delve commands for debugging Go programs, including tests and main programs.
- go.modhistorical
These notes record go.mod and Go module management through commands and configuration examples for project dependencies.
- godochistorical
Godoc can serve Go documentation locally for viewing in a browser. These notes record the startup command and local address.
- httphistorical
Go sends requests through helpers such as http.Get, Post, and PostForm, backed by Client. These notes continue with HTTP client and server usage.
- iohistorical
Go I/O operations involve packages such as io and os. These notes organize their interfaces through cross-platform file access and error handling.
- packagehistorical
Packages organize Go source code. These notes use source and test files to record package definitions, imports, and usage.
- sqlhistorical
Go's sql.DB can be shared by multiple goroutines. These notes record connection setup, queries, and connection validation.
- structhistorical
Go structs of the same type can be compared field by field. These notes examine equality, usage, and related restrictions.
- sync.singleflighthistorical
These notes use examples to examine singleflight and how simultaneous calls for the same request can share execution.
- xormhistorical
These notes record XORM configuration and commands, using configuration files and examples to show database integration.