简体   繁体   English

在Windows 64位中编译Go的问题

[英]Issue with Compiling Go in Windows 64bit

I have installed Go from gomingw for windows 64 bit. 我已经为Windows 64位从gomingw安装了Go。 However, I cannot find out anywhere how to actually compile a .go file. 但是,我找不到任何地方实际如何编译.go文件。 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. 这是直接从Go Wiki获得Windows支持链接的程序,但是所有教程都讨论了如何使用6g和gccgo等,但这些都无法在Windows机器上使用。 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. 实际上,我想做的是,将“ hello.go”放入src文件夹,转到src文件夹后,在命令提示符下运行命令“ 8g hello.go”。 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? 有人可以通过提供正确的步骤在Windows中编译go程序来帮助我吗? Thanks in advance. 提前致谢。

Navigate to your source code directory (for example, C:\\Arpsss), display the current directory, and display the current directory contents. 导航到源代码目录(例如C:\\ Arpsss),显示当前目录,并显示当前目录的内容。

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 . 尝试编译名为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. 这是您报告的错误-您试图编译一个不在当前目录中的名为a.go的文件。

Compile, link, and run the hello.go Go source file in the current directory. 在当前目录中编译,链接和运行hello.go Go源文件。

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

The hello.go program. hello.go程序。

package main

import "fmt"

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM