beldur / kraken-go-api-client

Example client library in GO for use with the kraken.com API.
MIT License
212 stars 142 forks source link

nill response from Trades #63

Open drakos74 opened 3 years ago

drakos74 commented 3 years ago

Sometimes lately, when making a Trades request i am getting the following error

panic: interface conversion: interface {} is nil, not []interface {}

goroutine 56 [running]:
github.com/beldur/kraken-go-api-client.(*KrakenAPI).Trades(0xc00007dda0, 0x9a6067, 0x6, 0x1663c1ef0f0ae825, 0x0, 0x0, 0x0)
    /home/ec2-user/Projects/free-coin/vendor/github.com/beldur/kraken-go-api-client/krakenapi.go:251 +0xa30

It seems it would be better to do a nil check, before casting the response ...

if v[pair] == nil {
    return nil, err
}
trades := v[pair].([]interface{})

Would it make sense to create a PR for this fix ?

Did anyone else encounter this one ?

beldur commented 2 years ago

Hi drakos74, a pull request would be appreciated.