gin icon indicating copy to clipboard operation
gin copied to clipboard

gin: command not found

Open andream16 opened this issue 8 years ago • 11 comments

Hi everybody, after doing go get github.com/codegangsta/gin and doing gin -h I get gin: command not found. I'm doing gin -h inside my GOPATH. I'm running on 4.4.63-1-MANJARO.

What's causing this?

andream16 avatar May 04 '17 14:05 andream16

Have a look at this post: cannot-set-gopath-on-mac-osx

All I needed to do was to make sure my GOPATH environment variable was set, then restart the terminal.

JBaczuk avatar May 26 '17 14:05 JBaczuk

I am having the same issue on mint 18.1 with go version go1.8.3 linux/amd64. The - gin -h 'gin: command not found'. When I run go env I see that my GOPATH is set to my workspace (GOPATH="/home/{user}/go"). This folder contains /src /bin /pkg folder's and I can see that gin is in the bin folder. When I run echo $PATH i see that GOPATH/bin (/go/bin) is in my PATH

gin will run if I use ~/go/bin/gin

kylerdanielster avatar Jun 19 '17 03:06 kylerdanielster

Same as for @kylerdanielster.

andream16 avatar Jun 19 '17 06:06 andream16

cp $GOPATH/bin/gin $GOROOT/bin

WangShayne avatar Nov 30 '18 06:11 WangShayne

The above worked !! Thank you so much @WangShayne

ayush-usf avatar May 18 '20 19:05 ayush-usf

Don't copy files anywhere, you'll pollute your system with random files in random locations, instead ensure your system is properly configured.

When you install Golang, you should perform two steps that unfortunately the installation does not take care of:

  1. Set up GOPATH in your environment. On *nix it could be e.g. $HOME/go, on Windows e.g. C:\source\go.
  2. Update your PATH to include $GOPATH/bin or %GOPATH%\bin. If your GOPATH is /home/user/go, include /home/user/go/bin to your PATH. If your GOPATH is /Users/user/go, include /Users/user/go to your PATH. If your GOPATH is C:\source\go include C:\source\go\bin in your PATH, and so on.
  3. Restart the applications in question - IDE, Terminals, etc. to ensure the PATH and GOPATH are properly updated, as the environment gets configured at the time the application starts, not at the time you try to run a command.
  4. Confirm the new environment is correct via go env and checking your PATH, e.g.

Linux, MacOS, etc.

echo $GOPATH
echo $PATH | grep $GOPATH

Windows

echo %GOPATH%
echo %PATH% | find "%GOPATH%"

lietu avatar Jun 30 '20 11:06 lietu

Hello Guys,

Fasttrack to 2022, I find myself is the same situation. I am using Macos monterey with go 1.19.1. I just used the gin install command as documented in a module supported project using go get and it's not any where I can run it from. Following couple of the suggestions here below is what I have:

❯ echo $GOPATH
/Users/username/go
❯ echo $PATH | grep $GOPATH
/opt/homebrew/Cellar/go/1.19.1/libexec/bin:/Users/username/go/bin:/Users/username/.sdkman/candidates/springboot/cu..........


❯ ls -lh /Users/username/go
total 0
drwxr-xr-x  7 username  staff   224B Sep 10 14:57 bin
drwxr-xr-x  4 username  staff   128B Jul  5 07:32 pkg

I do not have the gin installed in the bin folder of the $GOPATH, instead it's in the pkg/mod. Not sure what to do from there

❯ ls -lh /Users/username/go/pkg/mod/github.com/codegangsta/
total 0
dr-xr-xr-x  8 username  staff   256B Sep 18 11:12 [email protected]
dr-xr-xr-x  8 username  staff   256B Sep 18 11:12 [email protected]

kdjomeda avatar Sep 18 '22 12:09 kdjomeda

go get hasn't been the way to install binaries from go packages for some time, you need go install .. e.g. go install github.com/codegangsta/gin@latest

lietu avatar Sep 18 '22 13:09 lietu

Thanks @lietu that is helpful

kdjomeda avatar Sep 19 '22 12:09 kdjomeda

Sadly this PR above wasn't merged. In README.md it still says to invoke go get .... instead of go install ... That wasted some time to find out

AntonGrekov avatar Jan 05 '23 14:01 AntonGrekov

For me even thought i hat gin installed but it was not in go/bin folder so from the user root dir in terminal i installed gin again and now gin works

MariuzM avatar Jun 03 '23 06:06 MariuzM