Hacker News new | ask | show | jobs
by codezero 4594 days 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.
3 comments

It 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

The size of int on 64-bit systems was increased to 64 bits as of Go 1.1: http://golang.org/doc/go1.1#int
Cool, thanks for the clarification, this makes sense!
i := 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
Awesome, thanks!