How to properly install GO with paths and all?

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

How to properly install GO with paths and all?

问题

我已经安装了GO,并设置了路径,但是当我运行一个文件时,出现了以下错误:

错误!exec: "sqlboiler": 在$PATH中找不到可执行文件
exec: "sqlboiler": 在$PATH中找不到可执行文件
exec: "sqlboiler": 在$PATH中找不到可执行文件
退出状态 3

出了什么问题?

英文:

I have installed GO, setup the paths but when i run a file i get this error:

error!! exec: "sqlboiler": executable file not found in $PATH
exec: "sqlboiler": executable file not found in $PATH
exec: "sqlboiler": executable file not found in $PATH
exit status 3

What is going wrong?

答案1

得分: 5

安装说明很好,https://go.dev/doc/install。然而,在我的Ubuntu 20.4的wsl2上,建议的二进制文件路径不够。只有gogofmt被添加到*/usr/local/go/bin*。

我在.bashrc中添加了以下内容,因为在我的系统上,go install将二进制文件放在这个位置。

export PATH="$HOME/go/bin:$PATH"

请注意,二进制文件的路径可能因系统而异,所以你需要相应地进行调整。

使用go install安装的任何二进制文件都将在此路径下对你的shell可用。

例如:

$ go install github.com/volatiletech/sqlboiler/v4@latest
$ go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest

$ whereis sqlboiler
sqlboiler: /home/blue/go/bin/sqlboiler

可能还需要在系统上安装一些数据库包。我不确定这一点了。例如,如果你使用Postgres,可以添加一些Postgres库。你需要看看是否可以正常工作。

apt-get install postgresql-client-common postgresql-client-12
英文:

The installation instructions are good, https://go.dev/doc/install. However, for me un Ubuntu 20.4 in wsl2, the suggested path for the binaries wasn't enough. Only go and gofmt are added to /usr/local/go/bin.

I did add the below to my .bashrc, since go install puts the binaries in this location on my system.

export PATH="$HOME/go/bin:$PATH"

Note, that the path to the binaries may differ on your system, so you have to adjust it accordingly.

Any binary you install with go install that is added to this path will be available to your shell afterwards.

For example:

$ go install github.com/volatiletech/sqlboiler/v4@latest
$ go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest

$ whereis sqlboiler
sqlboiler: /home/blue/go/bin/sqlboiler

Potentially, you also need some database packages to your system. I am not sure on this any more. For example, you could add some Postgres libs if you are using Postgres. You have to see if it works without.

apt-get install postgresql-client-common postgresql-client-12

答案2

得分: 0

如何正确安装GO并设置路径?

  1. 使用安装程序(Windows)或存档(在Linux/Mac上提取到/usr/local)安装Go。
  2. 如果从存档安装,请手动将go二进制文件所在的目录路径(/usr/local/go)添加到PATH中。
  3. GOPATH设置为包含binpkgsrc子目录的目录路径。
  4. ${GOPATH}/bin添加到PATH中。

出了什么问题?

您运行的程序试图运行名为sqlboiler的可执行文件,但在PATH指定的任何目录中都找不到它。

英文:

> How to properly install GO with paths and all?

  1. Install Go with the installer (Windows) or archive (extract into /usr/local on Linux/Mac).
  2. When installing from archive, manually add the directory path where the go binary is located (/usr/local/go) to PATH.
  3. Set GOPATH to a directory path wherein to contain bin, pkg and src sub-directories.
  4. Add ${GOPATH}/bin to PATH.

> What is going wrong?

The program you are running is trying to run the executable sqlboiler, which cannot be found in any of the directories specified in PATH.

huangapple
  • 本文由 发表于 2022年1月24日 19:12:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/70832925.html
匿名

发表评论

匿名网友

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

确定