Golang访问原始Podio字段值

Hi Podio people (and maybe more specifically Andreas),

I'm trying to dig deeper into the Golang API library but bumping into my rookie Golang skills.

After doing a client.getItems(...) call I wish to loop over the fields inside of the items and only grab relevant portions. The end goal is that I can create a very much simplified json object like this

{
    1000: "John", // key = app field id, value = text
    5490: [{item_id: 4031294, app_id: 94392}],  // relations
    5163: [1,2,5] // categories
}

However I cannot seem to get a hold of the item.Fields nested Values struct {}. I tried using reflect but without any luck.

Could someone help me complete this code please?

for _, field := range item.Fields {
  switch field.PartialField.Type {
  case "text":
    simpleValue := field.Values.Value // not working as I can't access Value in struct {}
  }
}

Greetings, PJ

Try a type assertion

myTexts := field.Values.([]TextValue)

You can also check for a valid assertion so your program doesn't panic

 myTexts, assertionSucceeded := field.Values.([]TextValue)