Trying to deploy my GO application with Cloud SQL using gcloud app deploy
but build is failing every time with package not found error. Not sure where it is picking the GOPATH
from. Is it possible to change the GOPATH
in google cloud engine.
Step #0: main.go:9:2: cannot find package "github.com/gin-gonic/gin"
in any of: Step #0: /usr/local/go/src/github.com/gin-gonic/gin (from
$GOROOT) Step #0: /workspace/_gopath/src/github.com/gin-gonic/gin
(from $GOPATH) Step #0: main.go:10: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: main.go:8:2: cannot find package
"google.golang.org/appengine" in any of: Step #0:
/usr/local/go/src/google.golang.org/appengine (from $GOROOT) Step #0:
/workspace/_gopath/src/google.golang.org/appengine (from $GOPATH)
I have import statements to include the above libraries. My local GOPATH
is set to /Users/amar.jain/go/
and it is trying to use /workplace/_gopath/
I'm also using the GO App Engine SDK.
As mentioned in here, the following line should be deleted from the app.yaml
file when using Flexible environment:
api_version: go1
Compare an example of an app.yaml
file when in Flexible and Standard.
These are the options available when configuring the Flexible environment.
Are you using the app engine standard environment?
The app engine standard environment is picky about GOPATH, it does try to upload all files required but it often helps to vendor the dependancies and make sure the app.yaml is at the top level.
Ive had problems with the standard environment when using the standard go /cmd /pkg structure for example.