【发布时间】:2014-04-02 19:19:44
【问题描述】:
在 Mac OS X 下,我做了一个 brew install go。我还从这里下载了 Go IntelliJ IDE
http://go-ide.com/2011/08/09/goide_release_1_0_darwin.html
以下程序从命令行编译并运行良好,但如果我使用 GO IntelliJ IDE 则会出错:
can't find import: math/rand
导入时间似乎没问题,但 Duration 和 time.Millisecond 未定义。如果我删除这些东西并只运行“Hello World 版本”,程序就会编译并运行良好。
/**
* Created by IntelliJ IDEA.
* User: idf
* Date: 4/2/14
* Time: 1:59 PM
* To change this template use File | Settings | File Templates.
*/
package main
import (
"fmt"
"math/rand" /* causes problems */
"time"
)
func main() {
sleep := time.Duration(200) /* error: undefined: time.Duration */
time.Sleep(sleep * time.Millisecond) /* error: undefined: time.Millisecond */
rand.Intn(1000)
fmt.Println("Hello World")
}
【问题讨论】:
标签: intellij-idea go