Go makes it possible to specify padding in structs manually using the blank identifier for fields. Take the following data structure:
struct{
a int32
b int32
}
This will have the following representation:
We can use the blank identifier to specify padding manually and to optimize the data structure for a 64-bit architecture:
struct{
a int32
_ int32
b int32
_ int32
}
This will allow the application to store each int32 in its own memory location because the blank fields will be acting as padding: