在Linux上安装Go,测试失败 [英] Installing Go on Linux, testing fails

查看:178
本文介绍了在Linux上安装Go,测试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循此页尝试安装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

Go expects your source code to be in a directory called src.

这篇关于在Linux上安装Go,测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆