I'm trying deploy my server using Golang into Google Cloud Platform
I run gcloud app deploy cmd/web/app.yaml
And was return Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
Into the logs was print this:
Starting Step #0
Step #0: Pulling image: gcr.io/gcp-runtimes/go1-builder@sha256:[...]
Step #0: sha256:[...]: Pulling from gcp-runtimes/go1-builder
Step #0: Digest: sha256:[...]
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:[...]
Step #0: main.go:8:2: cannot find package "github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql" in any of:
Step #0: /usr/local/go/src/github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql (from $GOROOT)
Step #0: /workspace/_gopath/src/github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql (from $GOPATH)
Step #0: routes.go:5:2: cannot find package "github.com/bmizerany/pat" in any of:
Step #0: /usr/local/go/src/github.com/bmizerany/pat (from $GOROOT)
Step #0: /workspace/_gopath/src/github.com/bmizerany/pat (from $GOPATH)
Step #0: main.go:7:2: cannot find package "github.com/go-sql-driver/mysql" in any of:
Step #0: /usr/local/go/src/github.com/go-sql-driver/mysql (from $GOROOT)
Step #0: /workspace/_gopath/src/github.com/go-sql-driver/mysql (from $GOPATH)
Step #0: middleware.go:6:2: cannot find package "github.com/justinas/nosurf" in any of:
Step #0: /usr/local/go/src/github.com/justinas/nosurf (from $GOROOT)
Step #0: /workspace/_gopath/src/github.com/justinas/nosurf (from $GOPATH)
Step #0: handlers.go:7:2: cannot find package "myProject/pkg/forms" in any of:
Step #0: /usr/local/go/src/myProject/pkg/forms (from $GOROOT)
Step #0: /workspace/_gopath/src/myProject/pkg/forms (from $GOPATH)
Step #0: app.go:4:2: cannot find package "myProject/pkg/models" in any of:
Step #0: /usr/local/go/src/myProject/pkg/models (from $GOROOT)
Step #0: /workspace/_gopath/src/myProject/pkg/models (from $GOPATH)
Finished Step #0
ERROR
My gcloud configuration is correct because I have a connection to Google SQL and I save the data. I have the code in a Compute Engine, but I try to run gcloud app deploy cmd / web / app.yaml
on my pc
The error was in app.yaml
i don't have much idea why but i just delete into app.yaml
the line api_version: go1
External packages need to be local for the build to take place. Go programs are often comprised of packages from many different sources. Each one of these sources are pulled in from the GOPATH or from the standard library. (Source of Explanation)
Take a look at govendor. Govendor will create your vendor folder and add your external packages.
// init govendor
govendor init
# Add existing GOPATH files to vendor.
govendor add +external