drby30217 2011-11-28 14:10
浏览 38
已采纳

在Windows 64位中编译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条回答 默认 最新

  • drodsh7940 2011-11-28 15:52
    关注

    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!")
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看