Open hardikm9850 opened 1 month ago
Developer: Initiates the build process using the go build command with the source code file (main.go in this example).
GoCompiler: Takes over the compilation process:
GoLinker: Manages the linking process:
Developer: Receives the final output from the linker, which is the executable binary (main in this case), ready for deployment and execution
Allocate Memory: When the program allocates memory for new objects, Go decides whether to store them in the young generation (if they are young objects) or the old generation (if they are older or have survived previous collections).
Program Execution: The program continues to execute normally, and memory allocation and usage continue.
Garbage Collection Needed?: Periodically, Go checks if garbage collection is necessary based on factors like heap size, allocation rates, and memory pressure.
Stop The World (STW): During garbage collection, there are brief STW phases:
Sweeping: After marking, Go sweeps through memory regions to reclaim memory from unreachable objects.
Compaction (optional): If enabled (GOGC environment variable), Go may optionally compact the heap after sweeping to reduce fragmentation and improve memory locality.
Resume Program Execution: After garbage collection and optional compaction, the program resumes execution.
GoLang learning plan suggested by @abhishekbodhekar
✅ 1. go through the complete go-tour ✅ 2. Concurrency: Learn about goroutines, channels, and the sync package (waitgroups) ✅ 3. Error handling - with errors.New(), errors.Join(), erros.Is() etc ✅ 4. Interfaces: how an interface in Go can be used with different purposes (including empty interface) ✅ 5. Reflection ✅ 6. Generics ⌛️ 7. Testing
⌛️ 8. Profiling and Benchmarking ⌛️ 9. Dependency Management here ✅ 10. How a go binary is built? (What actually happens behind the scene) ✅ 11. How Go's garbage collection is done? (What method/algo is uses)
Cheatsheet