An interger constant is "int" type and takes "8" bytes memory on 64-bit system.
fmt.Println(unsafe.Sizeof(100)) // 8 > fmt.Println(reflect.TypeOf(100)) // int and an "int32" type value takes "4" bytes. var num int32 > fmt.Println(unsafe.Sizeof(num)) // 4 So in this case below, Is the memory usage "12" bytes in total? (Question 1) var num int32 = 100 > | | > 4 bytes + 8 bytes = 12 bytes and in this case below, Is the memory usage "16" bytes in total? (Question 2) because the integer constant "100" is "8" bytes first then it's converted to "int32" which is "4" bytes. var num int32 = int32(100) > | | | > 4 bytes + 4 bytes + 8 bytes = 16 bytes -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.