R
R
recloudor2016-06-02 15:47:49
go
recloudor, 2016-06-02 15:47:49

golang. Can you suggest what is the problem?

Error: invalid operation: post["attachments"] (type interface {} does not support indexing)

posts := wall["response"].(map[string]interface{})["items"].([]interface{})
  for _, post := range posts {
    attachments := post["attachments"].([]interface{})

    for _, attachment := range attachments {

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Semchenko, 2016-06-02
@0xcffaedfe

Captain obviously states that: post["attachments"] (the interface {} type does not support indexing).

A
Alexey, 2016-06-02
@gentee

It turns out posts has type []interface{}. Accordingly, post is of type interface{}, not map[string].

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question