Panic: runtime error: index out of range

Code

In order for the URL to work, you will need to run the code in your local environment. Thanks in advance.

The reply given by the server does only contain a single object, not an array, therefore you need to parse it into a Result, then it will work:

https://play.golang.org/p/sjG74AYqIgg

Hi. Appreciate the fast response. I tried what you suggested and the code simply returned an empty string.

Which code?

All I am able to see is the code from the playground, and sadly, the struct has a field ID int, while the actual ID in the JSON seems to be some kind of string. So you probably need to fix your struct. Which also misses at least one level outside of the result key.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.