App Engine Standard: Folder structure and imports?

xuanbao · · 428 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi there,</p> <p>I&#39;m having a frustrating issue with Google App Engine standard environment. I&#39;m creating a project made up of several microservices. I have created the following file structure:</p> <pre><code>project/ dispatch.yaml - events/ - app.yaml - main.go - routes.go - models/ - models.event.go - users/ - app.yaml - main.go </code></pre> <p>I import the models package using the full &#34;github.com/xxx/project/events/models&#34;.</p> <p>The dev_appserver.py gives me the following error:</p> <blockquote> <p>go-app-builder: Failed parsing input: app file models.event.go conflicts with same file imported from GOPATH</p> </blockquote> <p>To contrast, deploying the code to app engine works flawlessly.</p> <p>If I change the import to just &#34;models&#34; then the dev server works, but the deployment doesn&#39;t work.</p> <p>I&#39;ve been searching a lot but I&#39;m finding a lack of information and that which I do find, I can&#39;t seem to figure out where I&#39;m going wrong.</p> <p>Could someone please offer advice regarding my situation?</p> <hr/>**评论:**<br/><br/>softwaregav: <pre><p>You can&#39;t import packages lower than your <code>.yaml</code> for appengine. Try putting <code>main.go</code> and <code>app.yaml</code> in a folder named <code>server</code> or something similar.</p></pre>mvpmvh: <pre><p>to piggyback off this answer. I was dealing with OP&#39;s <em>exact</em> issue <em>all</em> day yesterday. I read all types of things to try and figure out what needed to be done. I just couldn&#39;t grasp the concept, initially. Eventually, I came to the understanding <a href="/u/softwaregav" rel="nofollow">/u/softwaregav</a> is correct. I think AppEngine looks for package source files at and below the directory level that the app.yaml file is declared. Try having your main.go and app.yaml file in the lowest level of that events dir (if you want to keep that project structure). </p> <p>you could also structure your project as prescribed <a href="https://cloud.google.com/appengine/docs/standard/go/runtime#Go_Organizing_Go_apps" rel="nofollow">by google</a></p> <p>and <a href="https://stackoverflow.com/questions/35608403/new-project-structure-for-google-app-engine" rel="nofollow">here</a></p> <p><a href="https://groups.google.com/forum/#!topic/google-appengine-go/7cVj5mn1XDI" rel="nofollow">thread with same issue</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

428 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传