govendor doesn't work from cmd

rjxby picture rjxby · Feb 10, 2017 · Viewed 9.8k times · Source

I try to use govendor in my project folder /d/projects/go/src/github.com/user/dbot

govendor init

but bash returns

bash: govendor: command not found

for installation I just follow instruction and use

go get -u github.com/kardianos/govendor

there is something else about what I need to know

$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\projects\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\VLADYS~1.KOC\AppData\Local\Temp\go-build082923582=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1

Answer

theeddieh picture theeddieh · Feb 11, 2017

If all you are doing is:

go get -u github.com/kardianos/govendor

then that just installs the govendor source files and dependencies. From go help get:

The -u flag instructs get to use the network to update the named
packages and their dependencies. By default, get uses the network 
to check out missing packages but does not use it to look for updates
to existing packages.

Your error:

bash: govendor: command not found

comes from the fact that the govendor binary is not under your PATH.

To fix this, first check that $GOPATH/bin is in your PATH, then run

go install github.com/kardianos/govendor

That will build govendor and put under $GOBIN (which by default is $GOPATH/bin).