在Golang AppEngine中如何创建一个子实体?

huangapple go评论84阅读模式
英文:

How do I create a child entity in Golang AppEngine?

问题

我正在尝试根据这里的文档创建一个基于Child实体:https://cloud.google.com/appengine/docs/standard/python/datastore/entities

当我初始化用户实例时,我遇到了一个错误"issing ',' in argument list",即使只有一个参数。

当我尝试在初始化时将父值分配给Prospect时,我得到了这个错误:
expected '==', found '='

func sign(w http.ResponseWriter, r *http.Request) {  
    c := appengine.NewContext(r)  
    zip, err := strconv.Atoi(r.FormValue("zip"))  
  
    //user := user.Current(c)  
    user = Client(name: "Bryan")   
    // error thrown "missing ',' in argument list"
    
    p = Prospect(parent=user )
    // error thrown: expected '==', found '='  
    p := Prospect{  
        Name:  r.FormValue("name"),  
        Zip:  zip,  
        Date:  time.Now(),  
    }  

看起来和文档中的示例一样,我做错了什么?

英文:

I'm attempting to create a Child entity based on the docs here: https://cloud.google.com/appengine/docs/standard/python/datastore/entities

When I intiate the user instance, I'm getting an error "issing ',' in argument list" even though there is only one agument.

When I attempt to assign the parent value to Prospect on initiation, I get this error:
expected '==', found '='

func sign(w http.ResponseWriter, r *http.Request) {  
    c := appengine.NewContext(r)  
    zip, err := strconv.Atoi(r.FormValue("zip"))  
  
    //user := user.Current(c)  
    user = Client(name: "Bryan")   
    // error thrown "missing ',' in argument list"
    
    p = Prospect(parent=user )
    // error thrown: expected '==', found '='  
    p := Prospect{  
        Name:  r.FormValue("name"),  
        Zip:  zip,  
        Date:  time.Now(),  
    }  

It looks just like the examples in the documentation, what am I doing wrong?

答案1

得分: 1

在使用App Engine文档并编写Go代码时,你会经常被重定向到Python文档。这是地球上最烦人的事情。在导航和点击链接后,始终检查你所在的URL。如果你在正确的位置,你应该在URL中找到"go"。如果显示的是python或java,请将其替换为go,并希望它存在。

所以你真正想要的页面是这个:https://cloud.google.com/appengine/docs/standard/go/datastore/entities

英文:

When using the App Engine docs and writing in Go, you constantly get redirected to the Python docs. It is the most annoying thing on the planet. Always check the URL you are at after navigation and clicking links. If you are in the right place, you should find "go" in the URL somewhere. If it shows python or java, replace it with go in the URL and hope it exists.

So the page you really want is this: https://cloud.google.com/appengine/docs/standard/go/datastore/entities

huangapple
  • 本文由 发表于 2017年3月25日 03:47:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/43007957.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定