英文:
Go newbie: how to run goroutines shell?
问题
我尝试运行shell-basic
,但没有任何反应。这是我尝试的步骤:
要运行这个示例,请使用go get下载并安装:
go get goroutines.com/shell-basic
这个命令会静默完成,并且我看到它已经下载了shell basic脚本,但是当我执行shell-basic
时,出现了以下错误:
$ shell-basic
-bash: shell-basic: command not found
我做错了什么,还是我漏掉了什么?
我对将go
作为scripts
运行很感兴趣。
英文:
I tried running shell-basic
but nothing happens. Here is what I tried:
> To run this example, download and install it with go get:
go get goroutines.com/shell-basic
which finishes silently and I see it downloaded the shell basic script but when i execute shell-basic
i get:
$ shell-basic
-bash: shell-basic: command not found
did I do something wrong, or am i missing something?
what i'm interested in is running go
as scripts
..
答案1
得分: 1
go get
命令将获取源代码并将其放置在您的Go路径中,请在shell中尝试运行echo $GOPATH
命令查看路径。如果go get
命令静默完成,将会发生以下情况。
然后,您需要进入该源代码:
cd $GOPATH/src/goroutines.com/shell-basic
之后,您必须在该代码库中运行go install
命令(或者您可以运行go install /path/to/the/code
命令)。
源代码将被放置在$GOPATH/bin
目录中,并且可执行。
当然,如果您没有设置GOPATH
,则以上所有操作都将无法正常工作。
英文:
go get
will fetch the source and put it in your Go path, try echo $GOPATH
in the shell. This is what happens if go get
finishes silently.
Then you want to go to that source:
> cd $GOPATH/src/goroutines.com/shell-basic
aftwards, you must run go install
inside the repo. (or you can run go install /path/to/the/code
.
The source will then be put in $GOPATH/bin
, and be executable.
Of course none of this will work if you don't have you GOPATH
set up.
答案2
得分: 0
我认为你没有设置GOBIN
。
你可以按照以下步骤进行操作:
export PATH=$PATH:$GOPATH/bin
或者,尝试运行$GOPATH/bin/shell-basic
。使用你的GOPATH
替换$GOPATH
。
英文:
I think you not set GOBIN
.
You can follow:
export PATH=$PATH:$GOPATH/bin
Or, try run $GOPATH/bin/shell-basic
.Use your gopath replace $GOPATH
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论