23

This is my code:

package main
import (
    "strconv"
    "fmt"
)
func main() {
    t := strconv.Itoa64(1234)
    fmt.Println(t)
}

Problem:

Why does it cause the following error message?

command-line-arguments .\test.go:7: undefined: strconv.Itoa64 [Finished in 0.2s with exit code 2]

Rene Knop
  • 1,788
  • 3
  • 15
  • 27
Yster
  • 3,147
  • 5
  • 32
  • 48

2 Answers2

63

This is because Itoa64 is not the name of a function in the strconv package. It looks like you really want.

t := strconv.FormatInt(1234, 10)

See http://golang.org/pkg/strconv/#FormatInt

Stephen Weinberg
  • 51,320
  • 14
  • 134
  • 113
  • Thank you so much Stephen, it is working! There is some **confusing** info on this subject, including: http://stackoverflow.com/questions/8344210/strconv-itoatime-nanoseconds-error/8344775#8344775 and http://golang.org/src/cmd/fix/strconv_test.go – Yster Aug 31 '12 at 18:09
  • 13
    `strconv.Itoa64` existed before Go 1. That is why there is conflicting information. – Stephen Weinberg Aug 31 '12 at 18:31
  • Thanks for the info. I often have trouble finding info while coding in go. What is your main source of info while coding in Go? – Yster Aug 31 '12 at 19:33
  • 1
    The IRC channel is a great source of help. Other than that I normally just use the spec, docs, and the code. – Stephen Weinberg Sep 11 '12 at 23:57
  • Thank you for the valuable comments. – Yster Sep 12 '12 at 05:15
0

You can simply convert like this

func main() {
    t := int64(1234)
    fmt.Println(t)
}
Marijan
  • 1,825
  • 1
  • 13
  • 18
Khurshid
  • 9
  • 2