donglian6625 2019-03-13 21:20
浏览 32

在App Engine中部署相对路径模块

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)