package
0.0.0-20241218053035-7817f0a70428
Repository: https://github.com/lets-learn-it/go-learning.git
Documentation: pkg.go.dev

# README

Alignment & Padding

  • Golang defines the concept of byte alignment in the structure struct. Appropriate adjustment of the field order can save a lot of memory.
  • Alignment speeds up memory access by generating code that requires one instruction each to read & write a memory location. without alignment, we may face a situation where the processor will have to use two or more instructions to access data located between addresses that are multiples of the size of the machine word.
  • To align with machine word size, compiler adds padding in struct fields.
typebytes
bool1
byte1
int8
float324
float648
string16
slice24
map8