Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File does not exist error when I run hello.go program

Tags:

windows

go

I am following go documentation and try to run hello.go. I am on Windows 7 and install go 1.1.2 using msi installer. I have file "C:\Go\pkg\tool\windows_386\8g.exe" (see dir output below), but when I do 'go.exe run hello.go', I get the file does not exist error.

Please help. Thank you.

C:\>go.exe run hello.go
go build command-line-arguments: exec: "C:\\Go\\pkg\\tool\\windows_386\\8g.exe":
 file does not exist

C:\>go.exe version
go version go1.1.2 windows/386

C:\>go.exe run hello.go
go build command-line-arguments: exec: "C:\\Go\\pkg\\tool\\windows_386\\8g.exe":
 file does not exist

C:\>dir C:\\Go\\pkg\\tool\\windows_386\\8g.exe
The specified path is invalid.

C:\>dir C:\Go\pkg\tool\\windows_386\\8g.exe
 Volume in drive C is Local Disk
 Volume Serial Number is C07E-54F5

 Directory of C:\Go\pkg\tool\windows_386

08/13/2013  07:04 AM         1,831,416 8g.exe
               1 File(s)      1,831,416 bytes
               0 Dir(s)  11,407,892,480 bytes free
like image 869
michael Avatar asked Oct 21 '22 02:10

michael


1 Answers

From issue 6224, this error happens if you had the environment variable PATHEXT set to only one extension, before running go.exe.

  1. set PATHEXT=.BAT
  2. go run hello.go

What is the expected output?
no errors and hello world program runs

What do you see instead?

go build command-line-arguments: 
exec: "c:\\Go\\pkg\\tool\\windows_386\\8g.exe": file does not exist

8g Windows 7 64bit go version go1.1.2 windows/386


On my computer (W7 64 bits), I have:

set pa
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

and everything runs just fine.

LookPath is called with "c:\Go\pkg\tool\windows_386\8g.exe" and the fact that PATHEXT is being set in an evil way let's say, make LookPath fails

like image 198
VonC Avatar answered Oct 27 '22 09:10

VonC