Need help to launch hello.go

259 views
Skip to first unread message

Avetis Sargsian

unread,
Apr 28, 2019, 9:45:20 AM4/28/19
to golang-nuts
Hi everyone, as you can see from the topic I am new to Go

I follow the instruction on this page https://golang.org/doc/code.html#Workspaces to launch hello.go and face some difficulties

So, I downloded and installed  MSI file foe Windows

Here is my Go version:
go version go1.12.4 windows/amd64

my go env:
set GOARCH=amd64
set GOBIN=F:\GoWorckspace\bin
set GOCACHE=C:\Users\Avetis\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=F:\GoWorckspace
set GOPROXY=
set GORACE=
set GOROOT=E:\Go
set GOTMPDIR=
set GOTOOLDIR=E:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Avetis\AppData\Local\Temp\go-build714242958=/tmp/go-build -gno-record-gcc-switches

GOPATH dir structure is:
-bin/
-pkg/
-src/
     -hello/
            hello.go


hello.go content:

  package main

  import (
  "fmt"
  )

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

when I am trying do go install I get this arror:
 F:\GoWorckspace\src\hello> go install hello.go
open C:\Users\Avetis\AppData\Local\Temp\go-build786217674\b001\exe\a.out.exe: The system cannot find the file specified.

I have tried different options, but all of them lead to same error:

PS F:\GoWorckspace\src> go install .\hello\hello.go
open C:\Users\Avetis\AppData\Local\Temp\go-build220985190\b001\exe\a.out.exe: The system cannot find the file specified.
PS F:\GoWorckspace\src> go install .\hello
open C:\Users\Avetis\AppData\Local\Temp\go-build247169354\b001\exe\a.out.exe: The system cannot find the file specified.
PS F:\GoWorckspace\src> go install hello
open C:\Users\Avetis\AppData\Local\Temp\go-build365645162\b001\exe\a.out.exe: The system cannot find the file specified.
PS F:\GoWorckspace\src> go build .\hello\hello.go
open C:\Users\Avetis\AppData\Local\Temp\go-build274908638\b001\exe\a.out.exe: The system cannot find the file specified.


I will appreciate any help on this, thanks!

AndersonQ

unread,
Apr 29, 2019, 1:06:18 PM4/29/19
to golang-nuts
Well, I don't have experience in Windows, but I'd suggest you to try:

1) get out of your GOPATH or set GO111MODULES=on
2) go mod init or go mod init hello
3) go mod tidy
4) go run main.go or go build && ./hello

Also, have a look at https://github.com/golang/go/wiki/Modules#quick-start

good luck!

Anderson

Uli Kunitz

unread,
Apr 29, 2019, 2:16:26 PM4/29/19
to golang-nuts
There is a problem with your C drive. Go uses it to store temporary files. The error messages says it cannot access a file that Go should have created there. It's either a full drive or a permission issues. You can change the location by changing the GOCACHE variable 

Avetis Sargsian

unread,
Apr 29, 2019, 5:20:09 PM4/29/19
to golang-nuts
Unfortunately changin GOCACHE variable didn't help
 
PS F:\GoWorckspace\src\hello> go env
set GOARCH=amd64
set GOBIN=F:\GoWorckspace\bin
set GOCACHE=F:\temp
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=F:\GoWorckspace
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Avetis\AppData\Local\Temp\go-build171002686=/tmp/go-build -gno-record-gcc-switches
 
PS F:\GoWorckspace\src\hello> go install
open C:\Users\Avetis\AppData\Local\Temp\go-build231890486\b001\exe\a.out.exe: The system cannot find the file specified.

andrey mirtchovski

unread,
Apr 29, 2019, 5:27:30 PM4/29/19
to Avetis Sargsian, golang-nuts
try setting GOTMPDIR. not sure what this corresponds to on windows,
but it will change where the go tool will create its temp files:

$ go run -x t.go
WORK=/var/folders/sp/06p28g2d0vs7gd2vhf26wl9m0000gn/T/go-build126372523
[...]
$ GOTMPDIR=/tmp/go go run -x t.go
WORK=/tmp/go/go-build661115935
[...]

Xiaohua(Tony) Guan

unread,
Apr 29, 2019, 6:26:20 PM4/29/19
to golang-nuts
What is the output of your "go build" under the dir?

Please give a pre and after capture.

Avetis Sargsian

unread,
Apr 30, 2019, 1:02:33 AM4/30/19
to golang-nuts
I set GOTMPDIR to E:\temp folder
and here is the result 

PS F:\GoWorckspace\src\hello> go install
open E:\temp\go-build447177998\b001\exe\a.out.exe: The system cannot find the file specified.

PS F:\GoWorckspace\src\hello> go build
open E:\temp\go-build140959642\b001\exe\a.out.exe: The system cannot find the file specified. 

PS F:\GoWorckspace\src\hello> go run hello.go
open E:\temp\go-build609689226\b001\exe\hello.exe: The system cannot find the file specified.
 

vaastav anand

unread,
Apr 30, 2019, 1:24:58 AM4/30/19
to golang-nuts
It could be due to some anti-virus scanner deleting files.
Here is the relevant issue : https://github.com/golang/go/issues/26195

Robert Solomon

unread,
Apr 30, 2019, 8:10:37 AM4/30/19
to golang-nuts
I use win 10. I have my code as subdirectories in src. I see that you don't. Hello/ is not in src/.

And I then run go install from within src/

I also do this on ubuntu.

andrey mirtchovski

unread,
Apr 30, 2019, 10:49:13 AM4/30/19
to Avetis Sargsian, golang-nuts
> PS F:\GoWorckspace\src\hello> go install
> open E:\temp\go-build447177998\b001\exe\a.out.exe: The system cannot find the file specified.

is this a school or work computer? if yes then a group policy may have
disabled the execution of exe files. supply the "-work" argument to go
build. it will print the working directory and will not delete it
after finishing its run. then you can navigate to it and see if the
.exe file is there at all. i imagine, since only the .exe is the
problem, you will be able to see all the other temporary files that go
created.

Avetis Sargsian

unread,
Apr 30, 2019, 11:42:04 AM4/30/19
to golang-nuts
GOPATH = F:\GoWorckspace
GOPATH dir structure is:
-bin/
-pkg/
-src/
     -hello/
            hello.go

This is my home computer and cause is not an antivirus programm, I tried to reapit everising with it uninstalled.
And here is resul running build command with -work argument

PS F:\GoWorckspace\src\hello> go build -work
WORK=E:\temp\go-build828919622
open E:\temp\go-build828919622\b001\exe\a.out.exe: The system cannot find the file specified.

andrey mirtchovski

unread,
Apr 30, 2019, 11:58:30 AM4/30/19
to Avetis Sargsian, golang-nuts
> PS F:\GoWorckspace\src\hello> go build -work
> WORK=E:\temp\go-build828919622
> open E:\temp\go-build828919622\b001\exe\a.out.exe: The system cannot find the file specified.

once you have done this you should be able to cd to
E:\temp\go-build828919622 and look around to see if any files have
been created, including b001\exe\a.out.exe.

Avetis Sargsian

unread,
Apr 30, 2019, 3:11:57 PM4/30/19
to andrey mirtchovski, golang-nuts
Ok there is one file in 
E:\temp\go-build828919622\b001\importcfg.link
end is empty in 

E:\temp\go-build828919622\b001\exe

this is content of importcfg.link
packagefile hello=C:\Users\Avetis\AppData\Local\go-build\ae\aecfeab49f117df031d74e0ca3aad783ba25f0524b981cbb74a2db671205fadd-d
packagefile fmt=C:\Go\pkg\windows_amd64\fmt.a
packagefile runtime=C:\Go\pkg\windows_amd64\runtime.a
packagefile errors=C:\Go\pkg\windows_amd64\errors.a
packagefile internal/fmtsort=C:\Go\pkg\windows_amd64\internal\fmtsort.a
packagefile io=C:\Go\pkg\windows_amd64\io.a
packagefile math=C:\Go\pkg\windows_amd64\math.a
packagefile os=C:\Go\pkg\windows_amd64\os.a
packagefile reflect=C:\Go\pkg\windows_amd64\reflect.a
packagefile strconv=C:\Go\pkg\windows_amd64\strconv.a
packagefile sync=C:\Go\pkg\windows_amd64\sync.a
packagefile unicode/utf8=C:\Go\pkg\windows_amd64\unicode\utf8.a
packagefile internal/bytealg=C:\Go\pkg\windows_amd64\internal\bytealg.a
packagefile internal/cpu=C:\Go\pkg\windows_amd64\internal\cpu.a
packagefile runtime/internal/atomic=C:\Go\pkg\windows_amd64\runtime\internal\atomic.a
packagefile runtime/internal/math=C:\Go\pkg\windows_amd64\runtime\internal\math.a
packagefile runtime/internal/sys=C:\Go\pkg\windows_amd64\runtime\internal\sys.a
packagefile sort=C:\Go\pkg\windows_amd64\sort.a
packagefile sync/atomic=C:\Go\pkg\windows_amd64\sync\atomic.a
packagefile math/bits=C:\Go\pkg\windows_amd64\math\bits.a
packagefile internal/poll=C:\Go\pkg\windows_amd64\internal\poll.a
packagefile internal/syscall/windows=C:\Go\pkg\windows_amd64\internal\syscall\windows.a
packagefile internal/testlog=C:\Go\pkg\windows_amd64\internal\testlog.a
packagefile syscall=C:\Go\pkg\windows_amd64\syscall.a
packagefile time=C:\Go\pkg\windows_amd64\time.a
packagefile unicode/utf16=C:\Go\pkg\windows_amd64\unicode\utf16.a
packagefile unicode=C:\Go\pkg\windows_amd64\unicode.a
packagefile internal/race=C:\Go\pkg\windows_amd64\internal\race.a
packagefile internal/syscall/windows/sysdll=C:\Go\pkg\windows_amd64\internal\syscall\windows\sysdll.a
packagefile internal/syscall/windows/registry=C:\Go\pkg\windows_amd64\internal\syscall\windows\registry.a

вт, 30 апр. 2019 г. в 18:57, andrey mirtchovski <mirtc...@gmail.com>:

andrey mirtchovski

unread,
Apr 30, 2019, 4:45:00 PM4/30/19
to Avetis Sargsian, golang-nuts
I'm sorry that I can't help more. It appears to me that the go builder
was able to create some of the temporary files it needs, but not
others. This is a very strange situation that I have not seen before.
Akin to having a full disk or otherwise exhausting the storage
availability.

I do not know how to diagnose any more of this on windows. Apologies.

Avetis Sargsian

unread,
May 1, 2019, 4:28:16 AM5/1/19
to golang-nuts
Anyway, thanks for try to help!
Actually I was able to instal Go on my mac computer, it took only 10 minutes))), so I will continue to study there ;)
Reply all
Reply to author
Forward
0 new messages