3 ms·
Do you know what version that happens in? I tested on my 32 and 64 bit platforms with golang 1.1 and a static definition of an integer results in type int (whic
by codezero 13y ago
Do you know what version that happens in? I tested on my 32 and 64 bit platforms with golang 1.1 and a static definition of an integer results in type int (which is explicitly 32 bit)
package main
import "fmt"
import "reflect"
func main() {
i := 3
z := reflect.ValueOf(i)
fmt.Printf("%s\n", z.Kind())
}
// $./test
// int
// $
It's my understanding that this intentional and won't change, only explicit declarations of int64 are 64-bit.
- aaronblohowiak 13y agoIt is implementation-specific (from the spec:) There is also a set of predeclared numeric types with implementation-specific sizes: uint either 32 or 64 bits int same size as uint uintptr an unsigned integer large enough to store the uninterpreted bits of a pointer value
- iand 13y agoi := 3 means declare i to be an "int", which is the default numeric type. The size of that int will vary from platform to platform. See http://golang.org/ref/spec#Numeric_types http://golang.org/ref/spec#Numeric_types
- codezero 13y agoAwesome, thanks!
- enneff 13y agoThe size of int on 64-bit systems was increased to 64 bits as of Go 1.1: http://golang.org/doc/go1.1#int http://golang.org/doc/go1.1#int
- codezero 13y agoCool, thanks for the clarification, this makes sense!