在Linux上安装Go,测试失败 [英] Installing Go on Linux, testing fails
问题描述
我遵循此页尝试安装Go。我已经下载了该文件并且没有问题地将其解压。我打开配置文件
文件并转到文件末尾插入指定的 export
行的位置。我创建了所有指定的目录来创建树结构,从bash shell运行 export
命令,创建 hello.go
文件按照指示。
I'm following the instructions at this page to try to install Go. I have downloaded the file and extracted it without issue. I opened the profile
file and went to the end of the file where I inserted the indicated export
line. I created all the indicated directories to make a tree structure, ran the export
command from the bash shell, created the hello.go
file as instructed.
然而,当我运行去安装github.com/user/hello
我得到错误
Yet when I run go install github.com/user/hello
I get the error
can't load package: package github.com/user/hello: cannot find package "github.com/user/hello" in any of:
/usr/local/go/src/github.com/user/hello (from $GOROOT)
/work/src/github.com/user/hello (from $GOPATH)
推荐答案
试试这个:
export GOPATH=$HOME/work
cd $GOPATH
mkdir src
mv github.com src/
Go期望您的源代码位于名为 src $ c $的目录中c>。
Go expects your source code to be in a directory called src
.
这篇关于在Linux上安装Go,测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!