dourao1968 2013-07-05 05:24
浏览 37
已采纳

使Go Webapp独立于Google App Engine

This question comes from working on my webapp, a feed reader written in Go. The code is available at http://github.com/matthewbauer/rivulet although that should not be necessary to answer the question.

I have a webapp written in Go that is running on Google's App Engine. It uses the usual common App Engine libraries like datastore, memcache, and user.

Is there any way to let my users run this app on their own without breaking App Engine compatibility?

Go now provides build constraints that exclude/include files based on target build platform:

// +build !appengine

So, I know that this is possible. But, my biggest problem is with my libraries that depend on App Engine: datastore, memcache, and user. I know other libraries provide datastore and memcache, and I can implement user on my own, but how would I go about wrapping it up?

I know that I can have them set up a development server with the SDK, but that might be too involved for some users. I want a single executable that normal Go projects provide. IS that possible?

If any examples exist, I haven't found them yet; any examples of App Engine independent webapps would be appreciated. I can learn by example.

  • 写回答

1条回答 默认 最新

  • dsebywql016137 2013-07-05 06:01
    关注

    You will probably have refactor your code.

    The basic rule of thumb will be anywhere you depend on an AppEngine package define your own interface for the way you use it. This will allow you decouple the app from the appengine libraries.

    Once you've defined those interfaces then you can start providing alternatives that satisfy the interfaces. You'll be able to plugin any Datastore or Memcache that satisfies the interfaces and your app will be able to both run on appengine or as a standalone with the alternatives.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?