douhui3330 2015-11-15 12:30
浏览 269

Golang:Hello world不会打印到屏幕上并且程序不会退出

When I run the following code with the command "go.exe run main.go", the program doesnt print text to the screen or exit.

package main

import "fmt"

func main(){
    fmt.Println("Hello world")
}

go.exe version = go version go.1.5.1 windows/amd64

set GOARCH=386

set GOBIN=

set GOEXE=.exe

set GOHOSTARCH=386

set GOHOSTOS=windows

set GOOS=windows

set GOPATH=C:\project

set GORACE=

set GOROOT=C:\Go

set GOTOOLDIR=C:\Go\pkg\tool\windows_386

set GO15VENDOREXPERIMENT=

set CC=gcc

set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0

set CXX=g++

set CGO_ENABLED=1

Any ideas what's wrong?

Thanks

EDIT:

I tried uninstalling the windows/amd64 version and installing windows/386 to no avail. It's installed in c:\Go and the PATH is set. I'm using windows 10.

Line feeds

package mainLF
LF
import "fmt"LF
LF
func main(){LF
    fmt.Println("Hello world")LF
}LF

The following doesn't print to the command prompt either.

package main

//import "fmt"

func main(){
    println("Hello world")
}

The following gives the error "fmt imported but not used" so it must be doing something.

package main

import "fmt"

func main(){

}

GOROOT is set to C:\Go\

PATH: C:\Go\bin

Image showing how I'm running the program

EDIT: New Image

Updated image

  • 写回答

1条回答 默认 最新

  • dtufl26404 2015-11-16 03:44
    关注

    Create a folder named ~/sample (Where ~ means your home directory) From the terminal you can do this by entering the following commands:

    mkdir sample
    

    Below program for hello world display

    package main
    import "fmt"
    func main() {
    fmt.Println("Hello World")
    }
    

    save it as main.go in the folder we just created. Open up a new terminal and type in the following:

    cd sample
    go run main.go
    
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站