Davincible / goinsta

Unofficial Instagram API written in Golang (v2022)
MIT License
183 stars 56 forks source link

json: cannot unmarshal array into Go struct field SearchResult.clear_client_cache of type bool #66

Open Pdaret opened 10 months ago

Pdaret commented 10 months ago

When'm using this code snippet for visiting the user profile i give this error:

profile, err := insta.VisitProfile(acc) if err != nil { log.Fatal(err) }

help me please

bencebansaghi commented 6 months ago

Same issue for me.

bencebansaghi commented 6 months ago

After a bit of digging the problem seems to be ClearClientCache field in the search.go file is declared as a bool, but the JSON response from Instagram's API contains an empty array for this field. To resolve this, I modified the struct declaration as follows:

// Original line commented out for reference
// ClearClientCache bool `json:"clear_client_cache"`
ClearClientCache []interface{} `json:"clear_client_cache"`

This change seems to fix the unmarshaling issue. However, I’m unsure if this modification might cause problems elsewhere in the future. If anyone is more familiar with the goinsta library or has insights into why this error occurred, your input would be greatly appreciated.