I created a Golang web application that supports the Google BigQuery project. This app has
import ( "context" "html/template" "log" "net/http" "regexp" "strings" "strconv" "cloud.google.com/go/bigquery" "google.golang.org/api/iterator" )
and a JSON file for the BigQuery security credentials. Locally, it works fine on localhost: 8080. Then I tried to host it using the Google App Engine, and I hit some errors.
To deploy the Google App Engine, I first installed the Google Cloud SDK locally, I ran gcloud init and installed
gcloud components install app-engine-go bq core gsutil gcloud beta app-engine-python
packages. I deleted the main () function from main.go, and in the project directory the YAML file. I ran
gcloud config set project {correct project ID}
and in the DOS window I launched
gcloud app deploy
in the project directory. I got this error (formatted for SO and for deleting personal information):
C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine>gcloud app deploy ERROR: (gcloud.app.deploy) Staging command [C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\goapp-stager.exe C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine\app.yaml C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine c:\-----\-----\appdata\local\temp\--------\--------] failed with return code [1]. -------------------------------------STDOUT------------------------------------- -------------------------------------STDERR------------------------------------- 2017/07/18 18:14:44 failed analyzing C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine: cannot find package "google.golang.org/appengine/socket" in any of: ($GOROOT not set) C:\Go Workspace\src\google.golang.org\appengine\socket (from $GOPATH) GOPATH: C:\Go Workspace\src\google
I traced this error to the imported
"cloud.google.com/go/bigquery"
package; another โtestโ application without cloud.google.com/go/bigquery works fine using this technique. I tried to import
google.golang.org/appengine/socket
in the application, and I got another compilation error; it looks like this page says itโs not even there. Then I tried the ideas in this vid using the original application, storing the original main () function in main.go. I typed
gcloud app deploy
in the Cloud Shell window. I got it
$ ---_---------@---------------X------ :~/bigqueryApp $ gcloud app deploy ERROR: (gcloud.app.deploy) Staging command [/google/google-cloud-sdk/platform/google_appengine/goroot-1.6/bin/go-app-stager /home/---_---------/bigqueryApp/app.yaml /tmp/---------/---------] failed with return code [1]. ------------------------------------ STDOUT ------------------------------------ ------------------------------------ STDERR ------------------------------------ 2017/07/18 21:30:23 failed analyzing /home/---_---------/bigqueryApp: cannot find package "google.golang.org/api/iterator" in any of: ($GOROOT not set) /home/---_---------/gopath/src/google.golang.org/api/iterator (from $GOPATH) /google/gopath/src/google.golang.org/api/iterator GOPATH: /home/---_---------/gopath:/google/gopath
error. The application explicitly imports the iterator package. I researched / experimented / etc. To fix errors in both methods, but no luck. If anyone has ideas: how to fix these errors, Id would like to know them and Id be thankful.
Thanks!