139

Im trying to convert an integer into an integer64 in go but im having no luck. Anyone know an easy way to do this?

AC3112
  • 1,461
  • 3
  • 10
  • 7
  • If you showed your code sample why it does not work. It works for me. http://play.golang.org/p/63GWAs8XAq – Max Oct 30 '12 at 10:50

3 Answers3

214

This is called type conversion :

i := 23
var i64 int64
i64 = int64(i)
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
27

This is probably obvious, but simplest:

i64 := int64(23)
Ryan Walls
  • 6,962
  • 1
  • 39
  • 42
3
i := 23
i64 := int64(i)
fmt.Printf("%T %T", i, i64) // to print the data types of i and i64
Anupam Ghosh
  • 314
  • 3
  • 10