无法在Go中编译测试程序。

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

cannot compile a test program in Go

问题

我已经将它解压到d:\,然后创建了另一个目录d:\testgo,在其中放置了两个文件:

代码:

package main
import "fmt"

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

以及用于运行编译的CMD文件:

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

但是我没有得到exe文件,而是得到了以下错误信息:

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

那么出了什么问题?

英文:

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

得分: 3

SET GOROOT=d:\Go

英文:

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.

huangapple
  • 本文由 发表于 2013年1月27日 03:50:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/14540922.html
匿名

发表评论

匿名网友

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

确定