English 中文(简体)
戈德的包装错误
原标题:rand package error in Go
  • 时间:2011-11-22 18:09:36
  •  标签:
  • go

我试图将“ExpFloat64()”功能称作“大包”(http://golang.org/pkg/rand/)。 但是,它有以下错误:“prog.go:4:进口,而不是使用:rand prog.go:7:未界定:ExpFloat64”。 谁能帮助我为什么会错过? 《刑法》如下。

package main

import "fmt"
import "rand"

func main() {
fmt.Println(ExpFloat64())
}
最佳回答

错误信息很好地解释了这一信息——在戈里,你可以不使用进口包裹。 这里,它说,你重新进口大地,而不是使用大地,所以要么使用,要么进口。 你的主要职能是:

fmt.Println(rand.ExpFloat64())
问题回答

除了Chris Bunch所说的话外,如果你真的想要使用包裹中的名称(例如ExpFloat64),你可以这样做:

import . "rand"




相关问题
minimum work size of a goroutine [closed]

Does anyone know approximately what the minimum work size is needed in order for a goroutine to be beneficial (assuming that there are free cores for the work to be offloaded to)?

How do you get the terminal size in Go?

How do I get the terminal size in Go. In C it would look like this: struct ttysize ts; ioctl(0, TIOCGWINSZ, &ts); But how to i access TIOCGWINSZ in Go

What do you use to write Go [closed]

I know its a bit too early, but I ve been trying out Go (Google s Programming Language) and its kindof annoying to write code in gedit. So, my question: What do you use to experiment with Go?

Shared memory vs. Go channel communication

One of Go s slogans is Do not communicate by sharing memory; instead, share memory by communicating. I am wondering whether Go allows two different Go-compiled binaries running on the same machine to ...

Embedding instead of inheritance in Go

What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description

热门标签