-2

I ran this:

cd $GOPATH && go get -u github.com/zricethezav/gitleaks

perplexingly, I now have this:

$GOPATH/
     src/
       github.com/
         gitleaks/

but there is not a bin/ folder ... I would have expected to see the bin folder here: $GOPATH/bin

did I do something wrong? How do I install the package so that the binary shows up? I tried running:

go install github.com/zricethezav/gitleaks

but after installing I don't see a bin/ folder...

The output of go env looks like:

GOARCH="amd64"
GOBIN="/Users/alex/go/bin"
GOCACHE="/Users/alex/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alex/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/st/159q4vsd64b69_x99dtzzt6m0000gn/T/go-build133179815=/tmp/go-build -gno-record-gcc-switches -fno-common"
  • Do you have `GOBIN` set? Did you try with `-v` or `-x` to see what the output is? `github.com/gitleaks/` != `github.com/zricethezav/gitleaks`, so I'm not sure how you go the former. – JimB May 10 '19 at 22:11
  • It looks like your `go install` package name has an extraneous prefix, `src/`. Keep in mind that `$GOPATH/src` is the directory where package source is stored. The actual package names are the parts of the pathnames that proceed `$GOPATH/src`. – ctt May 10 '19 at 22:12
  • yeah I just posted a half-answer, maybe that helps –  May 10 '19 at 22:14

3 Answers3

0

After go get, the gitleaks executable should be in $GO_PATH\bin directory, not in the $GO_PATH\src...\gitleaks.

See this: https://pocketgophers.com/go-install-vs-go-build/

Hildeberto
  • 414
  • 2
  • 8
0

I installed golang on MacOS with brew install go, and that apparently didn't put the main binaries in /usr/local/go, which is why my go get command failed.

so instead of using brew, I installed via: https://golang.org/doc/install?download=go1.12.5.darwin-amd64.pkg

and after installing using the .pkg file, there were files in /usr/local/go, so then my go get command worked.

My guess is that homebrew puts the go binaries in a different location than /usr/local/go which kinda sux but I could see why.

-1

If $GOPATH isn't go's root directory I think you have to create bin folder manually. I've manually created $GOPATH/bin folder and its working fine.