dongrao9436 2013-01-26 19:50
浏览 52
已采纳

无法在Go中编译测试程序

compiler: http://code.google.com/p/go/downloads/detail?name=go1.0.3.windows-386.zip&can=2&q=

I've unpacked it to d:\, then made another directory d:\testgo, where I put two files:

The code:

package main
import "fmt"

func main() {
  fmt.Println("Hello world!")
}

and the CMD file to run the compilation:

SET PATH=%PATH%;D:\go\bin
go build test.go
@pause>nul

And I got no exe but this:

test.go:3:8: import "fmt": cannot find package
package runtime: import "runtime": cannot find package

So what went wrong ?

  • 写回答

1条回答 默认 最新

  • douwen1915 2013-01-26 19:53
    关注

    The documentations says the following:

    If you chose a directory other than c:\Go, you must set the GOROOT environment variable to your chosen path.

    SET GOROOT=d:\Go should do it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献