如何在本地运行这个 Go 应用程序?

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

How to run this Go application locally?

问题

我想要能够在我的机器上从存储库https://github.com/jbowens/codenames中运行应用程序。这可能吗?

我尝试过的步骤:

  • 安装了Go,并添加了PATH变量。
  • 将存储库克隆到了正确的Go路径位置。
  • 打开命令提示符,并从"cmd"文件夹中运行了命令"go run main.go"。

我对Go一无所知,也许我只需要运行另一个命令或安装依赖项之类的。如果有人能够弄清楚这个问题,我会非常高兴!这是一个很棒的游戏,我想在我的机器上玩。

英文:

I want to be able to run the application from the repository https://github.com/jbowens/codenames locally on my machine. Is it possible?

Steps I've tried:

  • Installed Go. Added PATH variable.
  • Cloned the repository to my machine in the right go path location.
  • Opened command prompt and ran the command "go run main.go" from the "cmd" folder

I really don't know anything about Go so maybe I just have to run another command or install dependencies or whatever. If someone could figure this out I would be super happy! This is an awesome game I would like to play from my machine.

答案1

得分: 1

我猜你只是在cmd/codenames目录下输入go build,在该目录下创建一个名为'codenames'的二进制文件,并从那里运行。

不幸的是,该应用程序是硬编码的,它会在与二进制文件相对的./assets/目录中查找其资源。

所以你希望将二进制文件放在应用程序的根目录中:

  • cmd/codenames目录执行go build -o ../../run-me-from-here
  • 然后从应用程序的根目录执行./run-me-from-here

英文:

I'm guessing you are just typing go build from the cmd/codenames directory, creating a binary called 'codenames' in that directory and running from there.

Unfortunately the app is hard-coded to look for its assets in a ./assets/ directory relative to the binary.

So you want your binary in the root of the app:

i.e

  • from the cmd/codenames directory go build -o ../../run-me-from-here
  • then from the root of the app ./run-me-from-here

.

答案2

得分: 0

在Go语言中,本地运行它们非常简单。

我通常在我的本地Go目录中运行go get命令。

运行以下命令获取https://github.com/jbowens/codenames:

go get https://github.com/jbowens/codenames

英文:

Running them locally is very easy in go

I usually run go get while in my local go directory.

Go get https://github.com/jbowens/codenames

答案3

得分: -4

设置gopath和goroot,然后安装依赖项。

英文:

Set gopath and goroot then install dependencies.

huangapple
  • 本文由 发表于 2017年6月10日 05:45:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/44467121.html
匿名

发表评论

匿名网友

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

确定