How to properly install GO with paths and all?

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?


Solution 1:

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