简体   繁体   中英

How to use main package in different folder than app.yaml for appengine Go?

I am trying to upload a Go app to appegnine Go 1.12 runtime. My main pkg is under a cmd folder as shows https://cloud.google.com/appengine/docs/standard/go112/config/appref#runtime_and_app_elements

But if I try any of the approaches outlines in the official docs, I get the following error:

ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/home/tamal/go/src/kmodules.xyz/resource-metadata/app.yaml]
Unable to assign value './cmd/resource-metadata-server' to attribute 'main':
Value './cmd/resource-metadata-server' for main does not match expression '^(?:[\w.\\\/:]+)$'
  in "/home/tamal/go/src/kmodules.xyz/resource-metadata/app.yaml", line 3, column 7
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/home/tamal/go/src/kmodules.xyz/resource-metadata/app.yaml]
Unable to assign value 'kmodules.xyz/resource-metadata/cmd/resource-metadata-server' to attribute 'main':
Value 'kmodules.xyz/resource-metadata/cmd/resource-metadata-server' for main does not match expression '^(?:[\w.\\\/:]+)$'
  in "/home/tamal/go/src/kmodules.xyz/resource-metadata/app.yaml", line 2, column 7

The problem seems to be that I am not allowed to use - in the main entry in app.yaml. Why is that? Can this be fixed?

I am using

$ gcloud version
Google Cloud SDK 257.0.0
app-engine-go 
app-engine-python 1.9.86
beta 2019.05.17
bq 2.0.46
cloud-datastore-emulator 2.1.0
core 2019.08.02
gsutil 4.41

The error code suggests that the string passed on to main must match the regex ^(?:[\\w.\\\\\\/:]+)$ . This means that the supplied string must match any character inside the character set such as /w which can be any word character ( alphanumeric & underscore ), . which matches the . character, \\\\ which matches a \\ character, \\/ which matches a / character and : which matches a : character.

Notice that there isn't a - in the character set which would allow you to include the - character in the string supplied in main while respecting the regex it is constrained to. As such, so long as this constraint exclude - in the character set, main the expected string in the main attribute should be one that also excludes - while respecting the rest of the expression.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM