[英]Go - cannot compile hello world (Windows)
Just trying out Go, but I can't get it to compile my very first program. 只是尝试Go,但我无法编译我的第一个程序。 This caused a bunch of questions on the compiler. 这引起了编译器的一堆问题。
It is contained in this single file: 它包含在这个单独的文件中:
"D:\programming\Go\src\mytest\mytest.go"
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 help build
这是预期的结果。
>go build -v
_/D_/programming/Go/src/mytest
What are the _/D_/
things are??? 什么是_/D_/
东西是??? 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? 那么我做错了什么以及如何编译这个东西呢?
The main
function in a program must be in package main
. 程序中的main
功能必须在包main
。 Package main
can then import other packages and call them. 然后,包main
可以导入其他包并调用它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.