我正在尝试在Windows计算机上设置Go,
我按照本页https://golang.org/doc/code.html#Workspaces上的说明启动hello.go,并遇到了一些困难。
所以,我下载并安装了MSI文件
这是我的Go版本: go版本go1.12.4 Windows / amd64
我的环境:
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目录结构为: -bin / -pkg / -src / -你好/ hello.go
hello.go内容:
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World!")
}
当我尝试go install
时,我得到了这个错误:
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.
我尝试了不同的选项,但是所有这些都会导致相同的错误:
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.
答案 0 :(得分:-1)
您应该尝试在go install
目录而不是~/go/src/
中执行~/go/hello
命令。因此,尝试将hello目录移动到src
目录中。更好的方法是在放置项目的地方建立一个~/go/src/github.com/[YourGithubName]
目录。