在Windows 64位系统中编译Go的问题

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

Issue with Compiling Go in Windows 64bit

问题

我已经从gomingw安装了适用于64位Windows的Go。然而,我无法找到任何关于如何编译.go文件的信息。这个程序直接从Go维基链接到Windows支持,但是所有的教程都谈到使用6g和gccgo等等,而这些在我的Windows机器上都不起作用。实际上,我想做的是,我把我的"hello.go"文件放在src文件夹中,在进入src文件夹后,在命令提示符中运行命令"8g hello.go"。但是,它显示错误"打开a.go,没有这个文件或目录"。有人可以帮助我提供在Windows中编译Go程序的正确步骤吗?提前感谢。

英文:

I have installed Go from gomingw for windows 64 bit. However, I cannot find out anywhere how to actually compile a .go file. This is the program linked directly from the Go wiki for Windows Support, but all the tutorials talk about using 6g and gccgo etc. and none of those work on my windows machine. Actually, what I am trying to do is, I put my "hello.go" in src folder and after going to src folder I run the command "8g hello.go" in command prompt. But. it showing error "open a.go no such file or directory". Can anybody help me by providing correct steps to compile a go program in Windows? Thanks in advance.

答案1

得分: 1

导航到您的源代码目录(例如,C:\ Arpsss),显示当前目录,并显示当前目录内容。

C:\>cd C:\ Arpssss
C:\ Arpssss>cd
C:\ Arpssss
C:\ Arpssss>dir
 C驱动器中没有标签的卷。
 C:\ Arpssss的目录
11/28/2011 10:26 AM    <DIR>          .
11/28/2011 10:26 AM    <DIR>          ..
11/28/2011 10:24 AM                73 hello.go
               1个文件(s)             73字节
               2个目录(s)   4,949,831,680字节可用

尝试编译一个名为a.go的不存在的文件。

C:\ Arpssss>8g a.go
打开a.go:没有这样的文件或目录

这是您报告的错误-您尝试编译一个名为a.go的文件,但它不在您的当前目录中。

在当前目录中编译,链接并运行hello.go Go源文件。

C:\ Arpssss>8g hello.go
C:\ Arpssss>8l -o hello.exe hello.8
C:\ Arpssss>hello
你好,世界!

hello.go程序。

package main

import "fmt"

func main() {
	fmt.Println("Hello, World!")
}
英文:

Navigate to your source code directory (for example, C:\Arpsss), display the current directory, and display the current directory contents.

C:\>cd C:\Arpssss
C:\Arpssss>cd
C:\Arpssss
C:\Arpssss>dir
 Volume in drive C has no label.
 Directory of C:\Arpssss
11/28/2011  10:26 AM    <DIR>          .
11/28/2011  10:26 AM    <DIR>          ..
11/28/2011  10:24 AM                73 hello.go
               1 File(s)             73 bytes
               2 Dir(s)   4,949,831,680 bytes free

Try to compile a non-existent file named a.go.

C:\Arpssss>8g a.go
open a.go: No such file or directory

This is the error you reported--you tried to compile a file named a.go that wasn't in your current directory.

Compile, link, and run the hello.go Go source file in the current directory.

C:\Arpssss>8g hello.go
C:\Arpssss>8l -o hello.exe hello.8
C:\Arpssss>hello
Hello, World!

The hello.go program.

package main

import "fmt"

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

huangapple
  • 本文由 发表于 2011年11月28日 22:10:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/8297054.html
匿名

发表评论

匿名网友

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

确定