GAE(Google App Engine)平台上使用Go語言操作CRUD的範例程式碼, 資料庫使用GAE的Datastore。
Demo
Getting Started
-
申請 Google App Engine, Create Application, 請記下您的Application Identifier。
-
安裝Go Tools: http://golang.org/doc/install。
-
Clone:
git clone [email protected]:yfxie/go-lang-crud-on-gae.git cd go-lang-crud-on-gae/
修改app.yaml檔案, 將 Application Identifier 填入Step1所設的名稱
application: helloworld version: 1 runtime: go api_version: go1 handlers: - url: /.* script: _go_app
-
Local Testing:
dev_appserver.py .
Server: http://localhost:8080
AdminServer: http://localhost:8000
-
Deploy to GAE:
appcfg.py update .
Your app will running at http://yourname.appspot.com
Package
-
appengine
用來產生context的必要包, 與GAE相關的函數經常須使用context做為引數。
-
appengine/datastore
操作GAE Datastore的工具。
-
appengine/user
輕鬆實現Google使用者驗證。
-
fmt
純文字輸出用。
-
html/template
內建樣板引擎。
-
net/http
Server建路由。
-
strconv
字串形態轉換用。
-
time
Tools
- GoSublime: 好用的Sublime的Go套件, 自動完成、程式碼整理功能..etc。