strconv.Itoa64(1234)在golang中返回undefined。

huangapple go评论123阅读模式
英文:

strconv.Itoa64(1234) gives undefined in golang

问题

这是我的代码:

  1. package main
  2. import (
  3. "strconv"
  4. "fmt"
  5. )
  6. func main() {
  7. t := strconv.Itoa(1234)
  8. fmt.Println(t)
  9. }

问题:

为什么会导致以下错误信息?

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

英文:

This is my code:

  1. package main
  2. import (
  3. "strconv"
  4. "fmt"
  5. )
  6. func main() {
  7. t := strconv.Itoa64(1234)
  8. fmt.Println(t)
  9. }

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]

答案1

得分: 62

这是因为Itoa64不是strconv包中的一个函数的名称。看起来你真正想要的是:

  1. t := strconv.FormatInt(1234, 10)

请参考http://golang.org/pkg/strconv/#FormatInt

英文:

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

  1. t := strconv.FormatInt(1234, 10)

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

答案2

得分: 0

你可以简单地像这样转换

  1. func main() {
  2. t := int64(1234)
  3. fmt.Println(t)
  4. }
英文:

You can simply convert like this

  1. func main() {
  2. t := int64(1234)
  3. fmt.Println(t)
  4. }

huangapple
  • 本文由 发表于 2012年9月1日 01:21:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/12219911.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定