kubernetes-sigs / kubebuilder

Kubebuilder - SDK for building Kubernetes APIs using CRDs
http://book.kubebuilder.io
Apache License 2.0
7.77k stars 1.43k forks source link

go build is not downloading the required dependencies #786

Closed hpandeycodeit closed 5 years ago

hpandeycodeit commented 5 years ago

Description:

When running go build -o /output/path/kubebuilder ./cmd it doesn't download the required API's automatically under github.com (if running from $GOPATH) and throws the following errors:

cmd/webhook.go:26:2: cannot find package "github.com/gobuffalo/flect" in any of:
    /usr/local/Cellar/go/1.12.5/libexec/src/github.com/gobuffalo/flect (from $GOROOT)
    /Users/xx/go/src/github.com/gobuffalo/flect (from $GOPATH)
cmd/alpha.go:20:2: cannot find package "github.com/spf13/cobra" in any of:
    /usr/local/Cellar/go/1.12.5/libexec/src/github.com/spf13/cobra (from $GOROOT)
    /Users/xx/go/src/github.com/spf13/cobra (from $GOPATH)
cmd/api.go:27:2: cannot find package "github.com/spf13/pflag" in any of:
    /usr/local/Cellar/go/1.12.5/libexec/src/github.com/spf13/pflag (from $GOROOT)
    /Users/xx/go/src/github.com/spf13/pflag (from $GOPATH)

One has to manually download these dependencies under /go/src/github.com:

It complained about the following missing dependencies that I had to download manually to get it working:

git clone https://github.com/markbates/inflect.git
git clone https://github.com/gobuffalo/envy.git
git clone https://github.com/rogpeppe/go-internal.git
git clone https://github.com/joho/godotenv.git

If this is a manual step, can we modify the doc to include the above steps?

/kind bug

mengqiy commented 5 years ago

This issue is caused by go modules. You need to set GO111MODULE=on to use go modules when in GOPATH. Feel free to send a PR to update the contributor guide :)

mengqiy commented 5 years ago

You need to set it until go 1.13 is out this July. Go modules will be on by default in go 1.13