doucang9673 2015-12-02 02:20
浏览 67
已采纳

挂在Windows 10上的Go程序

I've been having issues with all Go programs hanging on Windows, even a simple Hello world program. I've reinstalled Golang multiple times with nothing changing. I can't use Ctrl+X or Ctrl+D to close the program either. It'll still spawn the process which will show up on Process Monitor. But I can't kill it from there or from the command line.

There was a similar issue to this posted on reddit https://www.reddit.com/r/golang/comments/2lvnqk/not_even_hello_world_works/. But that still has no resolution.

The is the program I'm trying to get to run right now:

package main

import "fmt"

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

Running it with go run -x gives this output:

WORK=C:\Users\User\AppData\Local\Temp\go-build882050150
mkdir -p $WORK\command-line-arguments\_obj\
mkdir -p $WORK\command-line-arguments\_obj\exe\
cd E:\go\src\github.com\test\hello
"C:\\Go\\pkg\\tool\\windows_amd64\\compile.exe" -o "C:\\Users\\User\\AppData\\Local\\Temp\\go-build882050150\\command-line-arguments.a" -trimpath "C:\\Users\\User\\AppData\\Local\\Temp\\go-build882050150" -p main -complete -buildid 0180ed6e175ea3e4bc497fc21fe0319a733a9c8e -D _/E_/go/src/github.com/test/hello -I "C:\\Users\\User\\AppData\\Local\\Temp\\go-build882050150" -pack "E:\\go\\src\\github.com\\test\\hello\\main.go"
cd .
"C:\\Go\\pkg\\tool\\windows_amd64\\link.exe" -o "C:\\Users\\User\\AppData\\Local\\Temp\\go-build882050150\\command-line-arguments\\_obj\\exe\\main.exe" -L "C:\\Users\\User\\AppData\\Local\\Temp\\go-build882050150" -w -extld=gcc -buildmode=exe -buildid=0180ed6e175ea3e4bc497fc21fe0319a733a9c8e "C:\\Users\\User\\AppData\\Local\\Temp\\go-build882050150\\command-line-arguments.a"
$WORK\command-line-arguments\_obj\exe\main.exe

After that it just sits there and dose nothing. Doesn't matter what program I run it will always hang forever.

No idea where to go from here. I don't really develop on Windows but I was trying to work with cross-compilation on Ubuntu and having run into this issue with the cross-compiled binary I thought I'd try compiling directly on Windows. But it appears my Windows just doesn't like Golang compiled binaries.

Go version is 1.5.1 windows/amd64.

Here's the output of go env:

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
  • 写回答

1条回答 默认 最新

  • duancong2965 2015-12-03 02:53
    关注

    Avast was being dumb. Disabled Avast and the programs all worked....

    Of course leaving Avast disabled is not ideal so I had to figure out a way to exclude go files. Unfortunately there's no way to exclude go compiled files themselves, unless you set up individual exclusions for the binaries. However excluding go specific directories will work.

    I ended up excluding the installation location of go for me this was C:\Go and the directory of GOPATH E:\go for me.

    This worked for the most part as long as binaries were run from either of those two directories, but I was still having issues with using the go run command. Using the go run -x command I was able to find out where Go was putting the temporary compiled binaries. This ended up being at C:\Users\username\AppData\Local\Temp\go-build1234\. However go would create a new directory each time I used go run so I had to create an exclusion on Avast with two wildcards set C:\Users\username\AppData\Local\Temp\go-build*\*. Now programs will run correctly.

    These are the exclusions I ended up with: Go Avast exclusions

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改