Golang Cloud SDK - gcloud deployment application cannot find import package

according to the official documentation for the Google App Engine Standard (Go API) environment, the “ preferred project deployment tool ” is now the SDK cloud, and so we switched to gcloud from goapp.

We cannot deploy Go projects to GAE because all subpackages of each specific project cannot be found at "deployment time". The typical folder structure that we used for each GAE project was as follows:

-project-name --app.yaml --main.go --assets ---package1 ---package2 

When the global libraries were put into the GOPATH system, everything worked smoothly.

Running gcloud app deploy , we get the following:

 You are about to deploy the following services: - yourproject/default/123456789 (from [/Path/to/app.yaml]) Deploying to URL: [https://yourproject.appspot.com] Do you want to continue (Y/n)? Y Beginning deployment of service [default]... ERROR: (gcloud.app.deploy) Staging command [/path/to/yourproject/app.yaml /var/folders/b6/5ydn0wdn64jd32sxzzz48b7c0000gn/T/tmpbd4oiG] failed with return code [1]. ------------------------------------ STDOUT ------------------------------------ ------------------------------------ STDERR ------------------------------------ 2017/03/24 10:25:58 failed analyzing /path/to/yourproject: cannot find package "yourpackage" in any of: ($GOROOT not set) /path/to/gopath/src/yourpackage (from $GOPATH) GOPATH: /path/to/gopath -------------------------------------------------------------------------------- 

while dev_appserver.py works great, keeping the same folder structure.

Did we miss something? How can we deploy to Google App Engine Standard using gcloud?

If you need to change the structure of the project: how? Is there any official documentation?

Thanks in advance,

Edit - Additional Information:

 Luigi-Mac-Pro:path/to/yourproject distudio$ gcloud version Google Cloud SDK 148.0.0 app-engine-go app-engine-go-darwin-x86_64 1.9.50 app-engine-python 1.9.50 bq 2.0.24 bq-nix 2.0.24 core 2017.03.17 core-nix 2016.11.07 gcloud gcloud-deps 2017.03.17 gcloud-deps-darwin-x86_64 2017.02.21 gsutil 4.23 gsutil-nix 4.22 
+5
source share
1 answer

Google recommends storing your dependencies outside the application directory and using GOPATH to link them. In your case, this will mean the following:

 -project-name --app.yaml --main.go 

where main.go contains

 import ( "package1" "package2" ) 

And somewhere else:

 -my_packages --src ---package1 ---package2 

And then set the GOPATH environment GOPATH to path/to/my_packages before running dev_appserver and gcloud app deploy .

In future

We are developing a long-term solution for the correct placement of packages inside your application catalog - most likely, with the help of Go of the future package manager. I'm sorry to say that we do not have a good way to support gcloud app deploy for gcloud app deploy . This was an unfortunate side effect of compatibility with the App Engine Flexible environment.

+3
source

Source: https://habr.com/ru/post/1265862/


All Articles