FAQ
Hi all,

I'm trying to store in a datastore locally but this is failing.
But am getting this error. "datastore: unsupported struct field type:
main.Location"
I believe I have done this on the appengine before (see screenshot below)
so think I can nest Locations within a profile.
Code is below any help is appreciated.

Regards,

John


*Error*

put failed
datastore: unsupported struct field type: main.Location



*Code*
jwprofile := new(Profile)
jwprofile.Id = "jwid"
jwprofile.Email = "john.a.whitton@gmail.com"
jwprofile.Name = "John Whitton"
jwprofile.Locations = make([]Location, 2)
jwprofile.Locations[0].Name = "Home"
jwprofile.Locations[0].Address = "629 Arguello Boulevard, San Francisco CA,
94118"
jwprofile.Locations[0].Lattitude = 37.7785645
jwprofile.Locations[0].Longtitude = -122.4590607
jwprofile.Locations[1].Name = "Work"
jwprofile.Locations[1].Address = "6750 Dumbarton Lane, Fremont CA, 94555"
jwprofile.Locations[1].Lattitude = 37.549830
jwprofile.Locations[1].Longtitude = -122.061506
fmt.Fprintln(w, jwprofile)

// key := datastore.NewKey(c, "Profile", p.Id, 0, nil)
// _, err := datastore.Put(c, key, p)
_, err := datastore.Put(c, datastore.NewKey(c, "Profile", jwprofile.Id, 0,
nil), jwprofile)
if err != nil {
fmt.Fprintln(w, "put failed")
http.Error(w, err.Error(), http.StatusInternalServerError)
}

*DataStore Entry*

<https://lh3.googleusercontent.com/-sI61Y90v0-I/Uq-jaogFGeI/AAAAAAAABjg/7W9EyA0ZoaM/s1600/DataStore.PNG>



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Kevin Gillette at Dec 17, 2013 at 1:44 am
    The screenshot is showing parallel arrays: Locations.Address is an
    array/list of addresses, Locations.Name is a list of names, where
    Locations.Address[0] corresponds to Locations.Name[0]. In Go, the
    screenshot essentially presents a struct of slices. What you're trying to
    store using the posted code is a slice of structs.
    On Monday, December 16, 2013 6:09:10 PM UTC-7, John Whitton wrote:

    Hi all,

    I'm trying to store in a datastore locally but this is failing.
    But am getting this error. "datastore: unsupported struct field type:
    main.Location"
    I believe I have done this on the appengine before (see screenshot below)
    so think I can nest Locations within a profile.
    Code is below any help is appreciated.

    Regards,

    John


    *Error*

    put failed
    datastore: unsupported struct field type: main.Location



    *Code*
    jwprofile := new(Profile)
    jwprofile.Id = "jwid"
    jwprofile.Email = "john.a....@gmail.com <javascript:>"
    jwprofile.Name = "John Whitton"
    jwprofile.Locations = make([]Location, 2)
    jwprofile.Locations[0].Name = "Home"
    jwprofile.Locations[0].Address = "629 Arguello Boulevard, San Francisco
    CA, 94118"
    jwprofile.Locations[0].Lattitude = 37.7785645
    jwprofile.Locations[0].Longtitude = -122.4590607
    jwprofile.Locations[1].Name = "Work"
    jwprofile.Locations[1].Address = "6750 Dumbarton Lane, Fremont CA, 94555"
    jwprofile.Locations[1].Lattitude = 37.549830
    jwprofile.Locations[1].Longtitude = -122.061506
    fmt.Fprintln(w, jwprofile)

    // key := datastore.NewKey(c, "Profile", p.Id, 0, nil)
    // _, err := datastore.Put(c, key, p)
    _, err := datastore.Put(c, datastore.NewKey(c, "Profile", jwprofile.Id, 0,
    nil), jwprofile)
    if err != nil {
    fmt.Fprintln(w, "put failed")
    http.Error(w, err.Error(), http.StatusInternalServerError)
    }

    *DataStore Entry*

    <https://lh3.googleusercontent.com/-sI61Y90v0-I/Uq-jaogFGeI/AAAAAAAABjg/7W9EyA0ZoaM/s1600/DataStore.PNG>


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nigel Tao at Dec 17, 2013 at 5:39 am

    On Tue, Dec 17, 2013 at 12:09 PM, John Whitton wrote:
    Code is below any help is appreciated.
    The important code, not shown, is what are the definitions of the
    Profile and Location types.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Whitton at Dec 17, 2013 at 6:04 am
    Here are the definitions
    type Location struct {
    Name string
    Address string
    Lattitude float64
    Longtitude float64
    }

    type Profile struct {
    Id string
    Email string
    Name string
    Locations []Location
    }

    And some relevant links the* bolded* one suggestst that it is fixed (not
    sure if it means that I can use embedded structures)

    https://developers.google.com/appengine/docs/go/datastore/

    https://developers.google.com/appengine/articles/datastore/overview

    https://developers.google.com/appengine/docs/go/datastore/reference

    https://groups.google.com/forum/#!topic/google-appengine-go/_11BOBesoqQ

    https://groups.google.com/forum/#!topic/google-appengine-go/hk-DQs4Uamk

    *https://code.google.com/p/googleappengine/issues/detail?id=6516*<https://code.google.com/p/googleappengine/issues/detail?id=6516>
    On Monday, December 16, 2013 5:09:10 PM UTC-8, John Whitton wrote:

    Hi all,

    I'm trying to store in a datastore locally but this is failing.
    But am getting this error. "datastore: unsupported struct field type:
    main.Location"
    I believe I have done this on the appengine before (see screenshot below)
    so think I can nest Locations within a profile.
    Code is below any help is appreciated.

    Regards,

    John


    *Error*

    put failed
    datastore: unsupported struct field type: main.Location



    *Code*
    jwprofile := new(Profile)
    jwprofile.Id = "jwid"
    jwprofile.Email = "john.a.whitton@gmail.com"
    jwprofile.Name = "John Whitton"
    jwprofile.Locations = make([]Location, 2)
    jwprofile.Locations[0].Name = "Home"
    jwprofile.Locations[0].Address = "629 Arguello Boulevard, San Francisco
    CA, 94118"
    jwprofile.Locations[0].Lattitude = 37.7785645
    jwprofile.Locations[0].Longtitude = -122.4590607
    jwprofile.Locations[1].Name = "Work"
    jwprofile.Locations[1].Address = "6750 Dumbarton Lane, Fremont CA, 94555"
    jwprofile.Locations[1].Lattitude = 37.549830
    jwprofile.Locations[1].Longtitude = -122.061506
    fmt.Fprintln(w, jwprofile)

    // key := datastore.NewKey(c, "Profile", p.Id, 0, nil)
    // _, err := datastore.Put(c, key, p)
    _, err := datastore.Put(c, datastore.NewKey(c, "Profile", jwprofile.Id, 0,
    nil), jwprofile)
    if err != nil {
    fmt.Fprintln(w, "put failed")
    http.Error(w, err.Error(), http.StatusInternalServerError)
    }

    *DataStore Entry*

    <https://lh3.googleusercontent.com/-sI61Y90v0-I/Uq-jaogFGeI/AAAAAAAABjg/7W9EyA0ZoaM/s1600/DataStore.PNG>


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nigel Tao at Dec 17, 2013 at 11:40 pm

    On Tue, Dec 17, 2013 at 5:04 PM, John Whitton wrote:
    (not sure if it means that I can use embedded structures)
    Yeah, your struct definitions look fine.

    What version of the App Engine SDK do you have?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Whitton at Dec 18, 2013 at 12:41 am
    release: "1.7.2"
    timestamp: 1345557405
    api_versions: ['go1']

    On Tuesday, December 17, 2013 3:40:03 PM UTC-8, Nigel Tao wrote:
    On Tue, Dec 17, 2013 at 5:04 PM, John Whitton wrote:
    (not sure if it means that I can use embedded structures)
    Yeah, your struct definitions look fine.

    What version of the App Engine SDK do you have?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • David Symonds at Dec 18, 2013 at 2:45 am
    That's ancient. Download the latest version.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Whitton at Dec 18, 2013 at 7:39 am
    David,

    Thank you, that fixed it.
    I'd somehow managed to download the go_appengine and google_appengine and
    set up my project using the old google_appengine.
    I downloaded the go_appengine again and used that and it now works.
    So it was just a sdk version issue.

    Thanks again.

    Regards,

    John
    On Tuesday, December 17, 2013 6:45:24 PM UTC-8, David Symonds wrote:

    That's ancient. Download the latest version.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Whitton at Dec 18, 2013 at 7:40 am
    Problem Fixed it was the version of the SDK I was running. Thank you all.
    On Monday, December 16, 2013 5:09:10 PM UTC-8, John Whitton wrote:

    Hi all,

    I'm trying to store in a datastore locally but this is failing.
    But am getting this error. "datastore: unsupported struct field type:
    main.Location"
    I believe I have done this on the appengine before (see screenshot below)
    so think I can nest Locations within a profile.
    Code is below any help is appreciated.

    Regards,

    John


    *Error*

    put failed
    datastore: unsupported struct field type: main.Location



    *Code*
    jwprofile := new(Profile)
    jwprofile.Id = "jwid"
    jwprofile.Email = "john.a.whitton@gmail.com"
    jwprofile.Name = "John Whitton"
    jwprofile.Locations = make([]Location, 2)
    jwprofile.Locations[0].Name = "Home"
    jwprofile.Locations[0].Address = "629 Arguello Boulevard, San Francisco
    CA, 94118"
    jwprofile.Locations[0].Lattitude = 37.7785645
    jwprofile.Locations[0].Longtitude = -122.4590607
    jwprofile.Locations[1].Name = "Work"
    jwprofile.Locations[1].Address = "6750 Dumbarton Lane, Fremont CA, 94555"
    jwprofile.Locations[1].Lattitude = 37.549830
    jwprofile.Locations[1].Longtitude = -122.061506
    fmt.Fprintln(w, jwprofile)

    // key := datastore.NewKey(c, "Profile", p.Id, 0, nil)
    // _, err := datastore.Put(c, key, p)
    _, err := datastore.Put(c, datastore.NewKey(c, "Profile", jwprofile.Id, 0,
    nil), jwprofile)
    if err != nil {
    fmt.Fprintln(w, "put failed")
    http.Error(w, err.Error(), http.StatusInternalServerError)
    }

    *DataStore Entry*

    <https://lh3.googleusercontent.com/-sI61Y90v0-I/Uq-jaogFGeI/AAAAAAAABjg/7W9EyA0ZoaM/s1600/DataStore.PNG>


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 17, '13 at 1:09a
activeDec 18, '13 at 7:40a
posts9
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase