Go Lang on AppEngine api_version 3 でいろいろ


Appengine SDKを1.6にアップグレード。
api_versionを2から3に変更。
するとエラーがたくさん。

undefined: “template”.MustParseFile
too many arguments in call to “template”.ParseFile
cannot use “Comment” (type string) as type “appengine”.Context in function argument:
string does not implement appengine.Context (missing AppID method)
cannot use nil as type string in function argument
not enough arguments in call to “appengine/datastore”.NewIncompleteKey

などなど。

以下が修正した箇所。

datastore.NewIncompleteKey("Comment", nil)
↓
datastore.NewIncompleteKey(c,"Comment", nil)

datastore.NewKey("Greeting", "", id, nil)	
↓
datastore.NewKey(c, "Greeting", "", id, nil)	

"template"
↓
"old/template"

templateが新しくなったようだが、取り敢えずの既存のやつを動かしたいので、oldにする。
datastoreから新しいキーを取得するときに contextを第一パラメータに追加。

以上で、api_version2で動いた奴が正常に動くようになった。

http://golangonengine.appspot.com/

Leave a comment