Go新手:如何运行goroutine shell?

huangapple go评论78阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2017年1月9日 01:02:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/41535292.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定