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

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

strconv.Itoa64(1234) gives undefined in golang

问题

这是我的代码:

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

问题:

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

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

英文:

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]

答案1

得分: 62

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

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.

t := strconv.FormatInt(1234, 10)

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

答案2

得分: 0

你可以简单地像这样转换

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

You can simply convert like this

func main() {
    t := int64(1234)
    fmt.Println(t)
}

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:

确定