On Mon, Aug 5, 2024 at 11:32 AM G K <gku...@gmail.com> wrote:
>
> I defined a global variable of the struct kind "Lock" as a slice - var Lock 
> []models.Lock
> But then every time I tried to unmarshal the data from the post call using 
> the the reference to &Lock, I was getting an error message that function 
> couldn't unmarshal the object into a Go value. It unmarshals fine you define 
> the var Lock model.Lock as just a struct.

Thanks, but rather than rephrasing into English, show us exactly what
you did, and exactly what happened.  Show us the exact code.  Tell us
the exact error message.  Thanks.

Ian


> On Monday, August 5, 2024 at 11:37:26 AM UTC-5 Ian Lance Taylor wrote:
>>
>> On Mon, Aug 5, 2024 at 6:55 AM G K <gku...@gmail.com> wrote:
>> >
>> > I'm trying to create an HTTP rest api end where a POST method will be able 
>> > to accept and deserialize (unmarshall) a same data structre into numerous 
>> > instances. For the sake of example, lets say I have json struct:
>> > type Lock struct
>> > {
>> > Key uint `json:"key"`
>> > }
>> > Nom Im trying to post unspecified amount of keys. I tried defying the type 
>> > as a slice but unmarshall function would not work. Does anyone have any 
>> > ideas how to go about this?
>>
>> Using a slice sounds like the right thing to do. What exactly did you
>> try and what exactly happened?
>>
>> Ian
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/aab40be8-a26f-49f4-b762-d8527963ddcen%40googlegroups.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXirXPVR9tZNgsw%2BVtmdnD%3DWJmQF_g4P6-bfWHRAe4%3DJA%40mail.gmail.com.

Reply via email to