Memory Allocation for a Struct in golang

type Employee struct {
ID int
Name string
Age int16
Gender string
Active bool
}
Employee struct size = 8(ID) + 16(Name) + 2(Age) + 16(Gender) + 1(Active) = 43 bytes
Size of main.Employee struct: 56 bytes
Memory Representation
type Employee struct {
Name string
Gender string
ID int
Age int16
Active bool
}
Size of main.Employee struct: 48 bytes

Love to write code and discuss technology | If you explain others is simple words it means you know it very well

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store