Cannot build Grafana from source with build.go

I’m using go version go1.11.1 darwin/amd64 on macOS 10.14. I have grafana checked out to $GOPATH/src/github.com/grafana/grafana on latest master (4a77a62949eaef72899b036b981b03a4266dc426 as of writing this).

When I run go run build.go setup, there are a lot of errors like:

pkg/api/pluginproxy/access_token_provider.go:14:2: cannot find package "golang.org/x/oauth2" in any of:
        /usr/local/opt/go/libexec/src/golang.org/x/oauth2 (from $GOROOT)
        /Users/james/src/golang.org/x/oauth2 (from $GOPATH)
pkg/components/imguploader/gcsuploader.go:13:2: cannot find package "golang.org/x/oauth2/google" in any of:
        /usr/local/opt/go/libexec/src/golang.org/x/oauth2/google (from $GOROOT)
        /Users/james/src/golang.org/x/oauth2/google (from $GOPATH)
pkg/api/pluginproxy/access_token_provider.go:18:2: cannot find package "golang.org/x/oauth2/jwt" in any of:
        /usr/local/opt/go/libexec/src/golang.org/x/oauth2/jwt (from $GOROOT)
        /Users/james/src/golang.org/x/oauth2/jwt (from $GOPATH)
pkg/services/alerting/engine.go:17:2: cannot find package "golang.org/x/sync/errgroup" in any of:
        /usr/local/opt/go/libexec/src/golang.org/x/sync/errgroup (from $GOROOT)
        /Users/james/src/golang.org/x/sync/errgroup (from $GOPATH)
pkg/log/log.go:13:2: cannot find package "gopkg.in/ini.v1" in any of:
        /usr/local/opt/go/libexec/src/gopkg.in/ini.v1 (from $GOROOT)
        /Users/james/src/gopkg.in/ini.v1 (from $GOPATH)
pkg/api/avatar/avatar.go:27:2: cannot find package "gopkg.in/macaron.v1" in any of:
        /usr/local/opt/go/libexec/src/gopkg.in/macaron.v1 (from $GOROOT)
        /Users/james/src/gopkg.in/macaron.v1 (from $GOPATH)
pkg/services/notifications/mailer.go:17:2: cannot find package "gopkg.in/mail.v2" in any of:
        /usr/local/opt/go/libexec/src/gopkg.in/mail.v2 (from $GOROOT)
        /Users/james/src/gopkg.in/mail.v2 (from $GOPATH)
pkg/services/provisioning/dashboards/config_reader.go:10:2: cannot find package "gopkg.in/yaml.v2" in any of:
        /usr/local/opt/go/libexec/src/gopkg.in/yaml.v2 (from $GOROOT)
        /Users/james/src/gopkg.in/yaml.v2 (from $GOPATH)

It looks like more Go dependencies need to be fetched, but running build.go does not do this?

Did you do go get github.com/grafana/grafana first or did you use git to clone the grafana repo - in that case remove checked out code/repo locally and then do a go get github.com/grafana/grafana followed by `go run build.go setup.

Yep that was it, I had originally just git cloned the repo into my $GOPATH, redoing with go get fixed it - thanks a lot!