Question about running hello.go

501 views
Skip to first unread message

michael.j....@gmail.com

unread,
Aug 21, 2013, 8:32:48 PM8/21/13
to golan...@googlegroups.com
I have installed go (using msi) on my windows 7 laptop.

When I run hello.go, I get this error? Please help

% go run hello.go
hello.go:3:8: cannot find package "fmt" in any of:
        \cygdrive\c\Programs\Go\src\pkg\fmt (from $GOROOT)
        \home\michael\go\src\fmt (from $GOPATH)
package runtime: cannot find package "runtime" in any of:
        \cygdrive\c\Programs\Go\src\pkg\runtime (from $GOROOT)
        \home\michael\go\src\runtime (from $GOPATH)

yxj1...@163.com

unread,
Aug 21, 2013, 10:28:46 PM8/21/13
to golan...@googlegroups.com, michael.j....@gmail.com
Hi, I have downloaded and installed my Go just a few minutes ago and it runs well. I am also Window 7 with my laptop . So please check if you have correctly set your enviroment variables.
 

在 2013年8月21日星期三UTC-5下午7时32分48秒,michael.j....@gmail.com写道:

brainman

unread,
Aug 21, 2013, 11:16:14 PM8/21/13
to golan...@googlegroups.com, michael.j....@gmail.com
Use windows command prompt, not cygwin shell.

Alex

michael.j....@gmail.com

unread,
Aug 22, 2013, 12:04:56 PM8/22/13
to golan...@googlegroups.com, michael.j....@gmail.com
I am still have the same problem.

I have re-installed go msi on windows 7. And it has go.exe in my path since it finds go.exe:
And I check I have 'C:\Go\pkg\tool\windows_386\8g.exe'

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
 Volume in drive C is Local Disk
 Volume Serial Number is C07E-54F5

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

08/22/2013  08:59 AM    <DIR>          .
08/22/2013  08:59 AM    <DIR>          ..
08/13/2013  07:04 AM           341,479 8a.exe
08/13/2013  07:04 AM         1,045,006 8c.exe
08/13/2013  07:04 AM         1,831,416 8g.exe
08/13/2013  07:04 AM           963,587 8l.exe
08/13/2013  07:04 AM           487,361 addr2line.exe
08/13/2013  07:04 AM         2,991,616 api.exe
08/13/2013  07:04 AM         3,153,408 cgo.exe
08/13/2013  07:04 AM           200,138 dist.exe
08/13/2013  07:04 AM         2,379,264 fix.exe
08/13/2013  07:04 AM           409,820 nm.exe
08/13/2013  07:04 AM           499,912 objdump.exe
08/13/2013  07:04 AM           365,998 pack.exe
08/13/2013  07:04 AM           156,981 pprof
08/13/2013  07:05 AM         6,548,480 tour.exe
08/13/2013  07:04 AM         2,854,912 vet.exe
08/13/2013  07:04 AM         1,709,568 yacc.exe
              16 File(s)     25,938,946 bytes
               2 Dir(s)  11,226,079,232 bytes free

atkaaz

unread,
Aug 22, 2013, 2:18:26 PM8/22/13
to michael.j....@gmail.com, golan...@googlegroups.com
I can't reproduce this on my Win7 64bit with Go 32bit
can you try
go.exe run -x hello.go

I'm getting something like this:
WORK=c:\temp\go-build874889363
mkdir -p $WORK\command-line-arguments\_obj\
mkdir -p $WORK\command-line-arguments\_obj\exe\
cd s:\!kill
"c:\\go\\pkg\\tool\\windows_386\\8g.exe" -o "c:\\temp\\go-build874889363\\command-line-arguments\\_
obj\\_go_.8" -p command-line-arguments -complete -D _/s_/_kill -I "c:\\temp\\go-build874889363" "s:
\\!kill\\hello.go"
"c:\\go\\pkg\\tool\\windows_386\\pack.exe" grcP "c:\\temp\\go-build874889363" "c:\\temp\\go-build87
4889363\\command-line-arguments.a" "c:\\temp\\go-build874889363\\command-line-arguments\\_obj\\_go_
.8"
cd .
"c:\\go\\pkg\\tool\\windows_386\\8l.exe" -o "c:\\temp\\go-build874889363\\command-line-arguments\\_
obj\\exe\\hello.exe" -L "c:\\temp\\go-build874889363" "c:\\temp\\go-build874889363\\command-line-ar
guments.a"
$WORK\command-line-arguments\_obj\exe\hello.exe
hello world



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

michael.j....@gmail.com

unread,
Aug 22, 2013, 2:34:42 PM8/22/13
to golan...@googlegroups.com, michael.j....@gmail.com
I tried 'go.exe run -x hello.go'

Here is the output:

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

C:\>go.exe run -x hello.go
WORK=C:\Temp\go-build260136667
mkdir -p $WORK\command-line-arguments\_obj\
mkdir -p $WORK\command-line-arguments\_obj\exe\
cd C:\
"C:\\Go\\pkg\\tool\\windows_386\\8g.exe" -o "C:\\Temp\\go-build260136667\\comman
d-line-arguments\\_obj\\_go_.8" -p command-line-arguments -complete -D _/C_ -I "
C:\\Temp\\go-build260136667" "C:\\hello.go"
go build command-line-arguments: exec: "C:\\Go\\pkg\\tool\\windows_386\\8g.exe":
 file does not exist



atkaaz

unread,
Aug 22, 2013, 2:49:37 PM8/22/13
to golan...@googlegroups.com
If you copy/paste the following line(with double quotes included) on the command line, does it work:

"C:\\Go\\pkg\\tool\\windows_386\\8g.exe"

michael.j....@gmail.com

unread,
Aug 22, 2013, 3:37:00 PM8/22/13
to golan...@googlegroups.com
Yes, it does work:


C:\>"C:\\Go\\pkg\\tool\\windows_386\\8g.exe"
usage: 8g [options] file.go...
  -+    compiling runtime
  -%    debug non-static initializers
  -A    for bootstrapping, allow 'any' type
  -B    disable bounds checking
  -D path
        set relative path for local imports
  -E    debug symbol export
  -I dir
        add dir to import search path
  -K    debug missing line numbers
  -L    use full (long) path in error messages
  -M    debug move generation
  -N    disable optimizations
  -P    debug peephole optimizer
  -R    debug register optimizer
  -S    print assembly listing
  -V    print compiler version
  -W    debug parse tree after type checking
  -complete
        compiling complete package (no C or assembly)
  -d    debug declarations
  -e    no limit on number of errors reported
  -f    debug stack frames
  -g    debug code generation
  -h    halt on error
  -i    debug line number stack
  -j    debug runtime-initialized variables
  -l    disable inlining
  -m    print optimization decisions
  -o obj
        set output file
  -p path
        set expected package import path
  -r    debug generated wrappers
  -race
        enable race detector
  -s    warn about composite literals that can be simplified
  -u    reject unsafe code
  -v    increase debug verbosity
  -w    debug type checking
  -x    debug lexer
  -y    debug declarations in canned imports (with -d)

C:\>

Matthew Kane

unread,
Aug 22, 2013, 4:08:31 PM8/22/13
to michael.j....@gmail.com, golang-nuts
Is there actually a file named c:\hello.go or is that somewhere else
on your filesystem?
matt kane
twitter: the_real_mkb / nynexrepublic
http://hydrogenproject.com

michael.j....@gmail.com

unread,
Aug 22, 2013, 4:10:46 PM8/22/13
to golan...@googlegroups.com, michael.j....@gmail.com
the file hello.go is in c:\

C:\> dir hello.go
 Volume in drive C is Local Disk
 Volume Serial Number is C07E-54F5

 Directory of C:\

08/22/2013  08:58 AM                82 hello.go
               1 File(s)             82 bytes
               0 Dir(s)  11,361,267,712 bytes free

atkaaz

unread,
Aug 22, 2013, 5:34:48 PM8/22/13
to golan...@googlegroups.com
ok, if you want, could you try to run:
go run -x -work hello.go
then, copy the entire command that failed, ie.:

"C:\\Go\\pkg\\tool\\windows_386\\8g.exe" -o "C:\\Temp\\go-build260136667\\comman
d-line-arguments\\_obj\\_go_.8" -p command-line-arguments -complete -D _/C_ -I "
C:\\Temp\\go-build260136667" "C:\\hello.go"

copy that into notepad, then make sure it's all one line (for me it requires 2 backspaces), so ie. looks like this:
"C:\\Go\\pkg\\tool\\windows_386\\8g.exe" -o "C:\\Temp\\go-build260136667\\command-line-arguments\\_obj\\_go_.8" -p command-line-arguments -complete -D _/C_ -I "C:\\Temp\\go-build260136667" "C:\\hello.go"

and then copy/paste it from notepad into the command line and execute it, curious if you get any errors.

the -work flag, doesn't delete the temporary folders/file for this go run.
the -x just shows the executed commands
the build number (go-build260136667) will change on every go run.

On another note, I've noticed that your drive letter is reported as uppercase and mine lowecase but from my tests trying to emulate the same thing, I was still unable to reproduce the error... sadly, but it makes sense that it's case insensitive.



On Thu, Aug 22, 2013 at 8:34 PM, <michael.j....@gmail.com> wrote:

michael.j....@gmail.com

unread,
Aug 22, 2013, 5:48:54 PM8/22/13
to golan...@googlegroups.com
I did what you suggested.

copy and paste the following in 1 line (I remove the new  line in notepad):

C:\"C:\\Go\\pkg\\tool\\windows_386\\8g.exe" -o "C:\\Temp\\go-build972859163\\command-line-arguments\\_obj\\_go_.8" -p command-line-arguments -complete -D _/C_ -I "C:\\Temp\\go-build972859163" "C:\\hello.go"

I get nothing as output. no error or anything.

Thank you.

atkaaz

unread,
Aug 22, 2013, 6:05:16 PM8/22/13
to golan...@googlegroups.com
(reposting reply 'cause was not sent to group, I must've clicked Reply again instead of Reply All)

Ok, in that case maybe someone who is a Go dev (or knows Go better?) could step in and guess why would go build fail to execute 8g.exe in this case...

relevant function:
https://code.google.com/p/go/source/browse/src/cmd/go/build.go?name=go1.1.2#1238

atkaaz

unread,
Aug 22, 2013, 6:33:13 PM8/22/13
to golan...@googlegroups.com
If I renamed 8g.exe so that it would seem to not exist, the error is:
go build command-line-arguments: exec: "C:\\Go\\Pkg\\Tool\\Windows_386\\8g.Exe": GetFileAttributesE
x C:\Go\Pkg\Tool\Windows_386\8g.Exe: The system cannot find the file specified.

(ignore the strings.Title() applied to strings, it is leftover from my tests)

michael.j....@gmail.com

unread,
Aug 22, 2013, 6:46:00 PM8/22/13
to golan...@googlegroups.com
Note, i need to do 'go.exe' instead of 'go'. I don't know why.

atkaaz

unread,
Aug 22, 2013, 6:47:01 PM8/22/13
to golan...@googlegroups.com
what happens if you do just go ? (paste?)

atkaaz

unread,
Aug 22, 2013, 6:54:03 PM8/22/13
to golan...@googlegroups.com
what if you do these 3 commands:
C:\Users\user>where go
C:\Go\bin\go.exe

C:\Users\user>which go
C:\Go\bin\go.EXE

C:\Users\user>go.com
'go.com' is not recognized as an internal or external command,
operable program or batch file.

(this might work if some virus...)


Also, what does the `go` as opposed to `go.exe` command say?

Do you have any antivirus or some kind of defense+ program(which could be blocking go from executing child programs for example) ?


michael.j....@gmail.com

unread,
Aug 22, 2013, 6:54:44 PM8/22/13
to golan...@googlegroups.com
It finds  'go.exe', but not 'go'

C:\>go
'go' is not recognized as an internal or external command,
operable program or batch file.

C:\>go.exe
Go is a tool for managing Go source code.

Usage:

        go command [arguments]

The commands are:

    build       compile packages and dependencies
    clean       remove object files
    doc         run godoc on package sources
    env         print Go environment information
    fix         run go tool fix on packages
    fmt         run gofmt on package sources
    get         download and install packages and dependencies
    install     compile and install packages and dependencies
    list        list packages
    run         compile and run Go program
    test        test packages
    tool        run specified go tool
    version     print Go version
    vet         run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

    gopath      GOPATH environment variable
    packages    description of package lists
    remote      remote import path syntax
    testflag    description of testing flags
    testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.


C:\>

michael.j....@gmail.com

unread,
Aug 22, 2013, 7:00:03 PM8/22/13
to golan...@googlegroups.com
I am runing these in a MS command prompt. (Get this via 'cmd' in run)

C:\>which go
'which' is not recognized as an internal or external command,
operable program or batch file.

C:\>where go
'where' is not recognized as an internal or external command,
operable program or batch file.

C:\>go.com
'go.com' is not recognized as an internal or external command,
operable program or batch file.

C:\>

atkaaz

unread,
Aug 22, 2013, 7:00:50 PM8/22/13
to golan...@googlegroups.com
that might be because of your PATHEXT environment variable, if I set mine to
set PATHEXT=.BAT

...well just look:

C:\Users\user>echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

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

C:\Users\user>set PATHEXT=.BAT

C:\Users\user>go

'go' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\user>go version

'go' is not recognized as an internal or external command,
operable program or batch file.

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


atkaaz

unread,
Aug 22, 2013, 7:04:43 PM8/22/13
to golan...@googlegroups.com
by the way, seting PATHEXT=.BAT
causes the exact error you've encountered
so fixing it should be as easy as:
set PATHEXT=
then run `go run hello.go`
should work
but curious what value was before...

atkaaz

unread,
Aug 22, 2013, 7:10:17 PM8/22/13
to golan...@googlegroups.com
To summarize:
c:\>echo %PATHEXT%
.BAT

c:\>go.exe run -x hello.go
WORK=C:\Temp\go-build515279051

mkdir -p $WORK\command-line-arguments\_obj\
mkdir -p $WORK\command-line-arguments\_obj\exe\
cd c:\
"c:\\go\\pkg\\tool\\windows_386\\8g.exe" -o "C:\\Temp\\go-build515279051\\command-line-arguments\\_
obj\\_go_.8" -p command-line-arguments -complete -D _/c_ -I "C:\\Temp\\go-build515279051" "c:\\hell
o.go"
go build command-line-arguments: exec: "c:\\go\\pkg\\tool\\windows_386\\8g.exe": file does not exist

c:\>set PATHEXT=

c:\>go.exe run -x hello.go
WORK=C:\Temp\go-build152222027

mkdir -p $WORK\command-line-arguments\_obj\
mkdir -p $WORK\command-line-arguments\_obj\exe\
cd c:\
"c:\\go\\pkg\\tool\\windows_386\\8g.exe" -o "C:\\Temp\\go-build152222027\\command-line-arguments\\_
obj\\_go_.8" -p command-line-arguments -complete -D _/c_ -I "C:\\Temp\\go-build152222027" "c:\\hell
o.go"
"c:\\go\\pkg\\tool\\windows_386\\pack.exe" grcP "C:\\Temp\\go-build152222027" "C:\\Temp\\go-build15
2222027\\command-line-arguments.a" "C:\\Temp\\go-build152222027\\command-line-arguments\\_obj\\_go_
.8"
cd .
"c:\\go\\pkg\\tool\\windows_386\\8l.exe" -o "C:\\Temp\\go-build152222027\\command-line-arguments\\_
obj\\exe\\hello.exe" -L "C:\\Temp\\go-build152222027" "C:\\Temp\\go-build152222027\\command-line-ar

guments.a"
$WORK\command-line-arguments\_obj\exe\hello.exe
hello, world

My normal PATHEXT however is:
set PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC

atkaaz

unread,
Aug 22, 2013, 7:51:46 PM8/22/13
to golan...@googlegroups.com
LookPath doesn't consider absolute paths on Windows, or so it seems, because the passed filename is an absolute path and .exe file and it cannot find it depending on PATHEXT which is unlike what the docs would imply

created issue: http://code.google.com/p/go/issues/detail?id=6224

michael.j....@gmail.com

unread,
Aug 22, 2013, 11:56:01 PM8/22/13
to golan...@googlegroups.com
Thanks for your help.
If I do this, it works!

c:\>set PATHEXT=


c:\>go.exe run -x hello.go


Reply all
Reply to author
Forward
0 new messages