2012-08-14 09:02
浏览 14

转到-无法编译Hello World(Windows)

Just trying out Go, but I can't get it to compile my very first program. This caused a bunch of questions on the compiler.

It is contained in this single file:


the program text is:

// mytest project mytest.go
package mytest

import "fmt"

func main() {
    fmt.Println("Hello, Go!")

In the package folder I tried the following commands:

>go build

says nothing. According to go help build this is the intended result.

>go build -v

What are the _/D_/ things are??? Looks like a new invention!

And the most strange one:

>go build -v mytest
can't load package: package mytest: import "mytest": cannot find package

So what am I doing wrong and how do I get the thing compiled?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongmou1964
    dongmou1964 2012-08-14 09:28

    The main function in a program must be in package main. Package main can then import other packages and call them.

    点赞 评论