I'm trying to setup Go on my Windows machine,
I followed the instruction on this page https://golang.org/doc/code.html#Workspaces to launch hello.go and face some difficulties.
So, I downloaded and installed MSI file
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 try 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 the 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.
You should try to do the go install
command in the ~/go/src/
directory and not in ~/go/hello
. So try to move hello directory into the src
directory. Even better would be to make a ~/go/src/github.com/[YourGithubName]
directory where you put your projects in.