my project's folder structure looks like this
/folder1
/feature1
feature1.go //package feature1
go.mod
/feature2
feature2.go //package feature2
go.mod
/web
app.yaml
cloudbuild.yaml
main.go //package main (starts app)
go.mod
this is inside my /web/go.mod
module mypackage
require(
//3rd party packages
feature1 v0.0.0
feature2 v0.0.0
)
replace(
feature1 => ../folder1/feature1
feature2 => ../folder1/feature2
)
if i run GO111MODULE=on go build
this compiles fine and i can run my project.
however, if i do a gcloud app deploy
i get the following errors:
go: parsing ../folder1/feature1/go.mod: open /tmp/staging614917184/folder1/feature1/go.mod: no such file or directory
go: parsing ../folder1/feature2/go.mod: open /tmp/staging614917184/folder1/feature2/go.mod: no such file or directory
these files definitely do exist in my project (otherwise the local go build would not have worked).
here is the relevant snippet of my app.yaml
runtime: go111
env: standard
before i switched to using go.mod, the app deployed fine via the gcloud cli.
however, i need to be able to specify a specific version for some of the packages i'm using, so i want to switch to using go modules.
with the above change, the gcloud builder works ok for the initial build step, but then fails on the app deploy step (gcloud app deploy)
does app engine not support relative paths in a go.mod? if so, is it possible to make this folder structure work?
EDIT:
this ended up being the key How to authenticate a private Go Module using go 1.11 and Google App Engine Standard
since in app engine deploys the root folder structure was not uploaded, a fix is to copy over the parent folders inside your subfolder where you house your app.yaml. then you point to that new subfolder in your go.mod using the replace syntax.